コード例 #1
0
ファイル: Bootstrap.php プロジェクト: azole/Phifty
function initConfigLoader()
{
    // We load other services from the definitions in config file
    // Simple load three config files (framework.yml, database.yml, application.yml)
    $loader = new ConfigLoader();
    if (file_exists(PH_APP_ROOT . '/config/framework.yml')) {
        $loader->load('framework', PH_APP_ROOT . '/config/framework.yml');
    }
    // This is for DatabaseService
    if (file_exists(PH_APP_ROOT . '/db/config/database.yml')) {
        $loader->load('database', PH_APP_ROOT . '/db/config/database.yml');
    } elseif (file_exists(PH_APP_ROOT . '/config/database.yml')) {
        $loader->load('database', PH_APP_ROOT . '/config/database.yml');
    }
    // Config for application, services does not depends on this config file.
    if (file_exists(PH_APP_ROOT . '/config/application.yml')) {
        $loader->load('application', PH_APP_ROOT . '/config/application.yml');
    }
    // Only load testing configuration when environment
    // is 'testing'
    if (getenv('PHIFTY_ENV') === 'testing') {
        if (file_exists(PH_APP_ROOT . '/config/testing.yml')) {
            $loader->load('testing', ConfigCompiler::compile(PH_APP_ROOT . '/config/testing.yml'));
        }
    }
    return $loader;
}
コード例 #2
0
ファイル: BuildConfCommand.php プロジェクト: azole/Phifty
 public function execute()
 {
     $configPath = func_get_args();
     // should we scan config directories ?
     if (empty($configPath)) {
         $configPath = array_filter(array('config/application.yml', 'config/framework.yml', 'config/database.yml', 'config/testing.yml'), function ($file) {
             return file_exists($file);
         });
     }
     if (empty($configPath)) {
         die("No config found.");
     }
     foreach ($configPath as $path) {
         $this->logger->info("Building config file {$path}");
         ConfigCompiler::compile($path);
     }
     $this->logger->info('Done');
 }
コード例 #3
0
ファイル: ConfigLoader.php プロジェクト: appleboy/LazyRecord
 public static function compile($sourceFile, $force = false)
 {
     $compiledFile = ConfigCompiler::compiled_filename($sourceFile);
     if ($force || ConfigCompiler::test($sourceFile, $compiledFile)) {
         $config = ConfigCompiler::parse($sourceFile);
         $config = self::preprocessConfig($config);
         ConfigCompiler::write($compiledFile, $config);
         return $config;
     } else {
         return require $compiledFile;
     }
 }
コード例 #4
0
ファイル: ComposerInstaller.php プロジェクト: azole/Phifty
 public static function postInstall(CommandEvent $event)
 {
     $composer = $event->getComposer();
     echo "Creating directory structure...\n";
     $dirs = array();
     $dirs[] = 'bin';
     $dirs[] = 'cache' . DIRECTORY_SEPARATOR . 'view';
     $dirs[] = 'cache' . DIRECTORY_SEPARATOR . 'config';
     $dirs[] = 'applications';
     $dirs[] = 'config';
     foreach ($dirs as $dir) {
         futil_mkdir_if_not_exists($dir, 0755, true);
     }
     echo "Installing main.php\n";
     if (!file_exists('main.php')) {
         copy('vendor/corneltek/phifty-core/main_app.php', 'main.php');
     }
     if (!file_exists('config/framework.yml')) {
         echo "Installing default framework config...\n";
         $appId = basename(getcwd());
         $appName = ucfirst(basename(getcwd()));
         $uuid = UUID::v4();
         $domain = $appId . '.dev';
         echo "ApplicationId: {$appId}, Domain: {$domain}, UUID: {$uuid}\n";
         $content = self::createConfigFromTemplate($appId, $appName, $uuid, $domain);
         file_put_contents("config/framework.yml", $content);
     }
     if (!file_exists('config/database.yml')) {
         echo "Installing default database config...\n";
         copy('vendor/corneltek/phifty-core/config/database.yml', 'config/database.yml');
         echo "Rewriting database config...\n";
         $config = ConfigCompiler::load('config/database.yml');
         $config['data_sources']['default'] = array('database' => basename(getcwd()), 'driver' => 'mysql', 'host' => 'localhost', 'user' => 'user', 'pass' => 'pass');
         file_put_contents("config/database.yml", yaml_emit($config));
     }
     if (!file_exists('locale')) {
         echo "Installing locale...\n";
         passthru('rsync -r vendor/corneltek/phifty-core/locale/ locale/');
     }
     if (!file_exists('webroot')) {
         passthru('rsync -r vendor/corneltek/phifty-core/webroot/ webroot/');
     }
     echo "Changing permissions...\n";
     $chmods = array();
     $chmods[] = array("og+rw", "cache");
     $chmods[] = array("og+rw", "webroot" . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'upload');
     foreach ($chmods as $mod) {
         list($mod, $path) = $mod;
         if (!file_exists($path)) {
             mkdir($path, 0755, true);
         }
         system("chmod -R {$mod} {$path}");
     }
     if (!file_exists('.gitignore')) {
         copy('vendor/corneltek/phifty-core/.gitignore', '.gitignore');
     }
     echo "Done";
 }
コード例 #5
0
ファイル: Bundle.php プロジェクト: corneltek/phifty
 public function saveTranslation($locale, $dict)
 {
     $file = $this->getTranslationDir() . DIRECTORY_SEPARATOR . $locale . '.yml';
     return ConfigCompiler::write_yaml($file, $dict);
 }