Beispiel #1
0
 /**
  * Load compiled configuration from cache, if available
  * @return Kernel
  * @throws KernelException
  */
 public function loadCachedConfig() : Kernel
 {
     if ($this->bootstrapped) {
         // Already bootstrapped?
         throw KernelException::bootstrapped();
     }
     $configFile = sprintf("bootstrap.config_%s.php.cache", $this->env);
     if (!isset($this->config)) {
         // Check if cached config file exists and is readable
         $cache = $this->disks->pull("cache");
         try {
             $config = unserialize($cache->read($configFile));
         } catch (DiskException $e) {
         }
         if (isset($config) && $config instanceof Config) {
             // Configuration loaded from cache
             $this->config = $config;
         } else {
             // Load fresh configuration
             $this->readConfig();
             // Save to cache
             $cache->write($configFile, serialize($this->config), Disk::WRITE_FLOCK);
         }
     }
     return $this;
 }