Example #1
0
 /**
  * Factory method for creating a configution for a PHP file and
  * optionally an .env.json file
  * @param type $filename
  * @return \Blend\Component\Configuration\Configuration
  * @throws FileNotFoundException
  */
 public static function createFromFile($filename)
 {
     if (file_exists($filename)) {
         $params = json_decode(file_get_contents($filename), true);
         $config = new Configuration($params);
         $envfile = dirname($filename) . '/.env.json';
         if (file_exists($envfile)) {
             $envparams = json_decode(file_get_contents($envfile), true);
             $config->mergeWith($envparams);
         }
         return $config;
     } else {
         throw new FileNotFoundException($filename, 500);
     }
 }
Example #2
0
 public function __construct(Configuration $config, LoggerInterface $logger, LocalCache $localCache, $rootFolder)
 {
     /**
      * Calling the initialize from the constructor will force some of
      * services to be instantiated early on which will result these object
      * beserialized too when the Application is being cached
      */
     $this->rootFolder = $rootFolder;
     $this->routeCollection = new RouteCollection();
     $this->localCache = $localCache;
     $this->logger = $logger;
     $config->mergeWith(['app.root.folder' => $rootFolder]);
     $this->initialize($config);
 }