/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (file_exists('symfony')) { throw new sfCommandException(sprintf('A project named "%s" already exists in this directory.', $arguments['name'])); } // create basic project structure $finder = sfFinder::type('any')->discard('.sf'); $this->getFilesystem()->mirror(dirname(__FILE__) . '/skeleton/project', sfConfig::get('sf_root_dir'), $finder); // update project name and directory $finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini'); $this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); // update ProjectConfiguration class $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'))); $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); $fixPerms->run(); }
protected function execute($arguments = array(), $options = array()) { $plugin = $arguments['plugin']; // Validate the application name if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $plugin)) { throw new sfCommandException(sprintf('The OpenPNE plugin name "%s" is invalid.', $plugin)); } $opPluginDir = sfConfig::get('sf_plugins_dir') . '/' . $plugin; if (is_dir($opPluginDir)) { throw new sfCommandException(sprintf('The OpenPNE plugin "%s" already exists.', $opPluginDir)); } // create basic opPlugin structure $finder = sfFinder::type('any')->discard('.sf'); $this->getFilesystem()->mirror(dirname(__FILE__) . '/skeleton/opPlugin', $opPluginDir, $finder); $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); @$fixPerms->run(); }
protected function execute($arguments = array(), $options = array()) { parent::execute($arguments, $options); $webCacheDir = sfConfig::get('sf_web_dir') . '/cache'; $this->getFilesystem()->chmod($webCacheDir, 0777); $dataDir = sfConfig::get('sf_data_dir') . '/config'; $fileFinder = sfFinder::type('file'); $this->getFilesystem()->chmod($fileFinder->in($dataDir), 0666); }
protected function execute($arguments = array(), $options = array()) { ini_set('memory_limit', '128M'); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); // delete previous tables $deleteTablesTask = new deleteTablesTask($this->dispatcher, $this->formatter); $return = $deleteTablesTask->run(array(), array('no-confirmation', 'connection' => $options['connection'])); if ($return) { return $return; } // generates Propel model and form classes, SQL and initializes the database $propelBuildAllTask = new sfPropelBuildAllTask($this->dispatcher, $this->formatter); $return = $propelBuildAllTask->run(array(), array('no-confirmation')); if ($return) { return $return; } // loads YAML fixture data $propelDataLoadTask = new sfPropelDataLoadTask($this->dispatcher, $this->formatter); $return = $propelDataLoadTask->run(array(), array()); if ($return) { return $return; } // clear cache $clearCacheTask = new cacheClearTask($this->dispatcher, $this->formatter); $return = $clearCacheTask->run(array(), array()); if ($return) { return $return; } // clear log $clearLogTask = new logClearTask($this->dispatcher, $this->formatter); $return = $clearLogTask->run(array(), array()); if ($return) { return $return; } // permission $permissionsTask = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $return = $permissionsTask->run(array(), array()); if ($return) { return $return; } return 0; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (file_exists('symfony')) { throw new sfCommandException(sprintf('A project named "%s" already exists in this directory.', $arguments['name'])); } // create basic project structure $finder = sfFinder::type('any')->discard('.sf'); $this->getFilesystem()->mirror(dirname(__FILE__) . '/skeleton/project', sfConfig::get('sf_root_dir'), $finder); // update project name and directory $finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini', 'databases.yml'); $this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); // update ProjectConfiguration class $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'))); // update vhost sample file $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/vhost.sample', '##', '##', array('PROJECT_NAME' => $arguments['name'], 'SYMFONY_WEB_DIR' => sfConfig::get('sf_web_dir'), 'SYMFONY_SF_DIR' => realpath(sfCoreAutoload::getInstance()->getBaseDir() . '../data/web/sf'))); // fix permission for common directories $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); $fixPerms->run(); // publish assets for core plugins $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); $publishAssets->run(array(), array('--core-only')); }
protected function execute($arguments = array(), $options = array()) { parent::execute($arguments, $options); $webCacheDir = sfConfig::get('sf_web_dir') . '/cache'; if (!is_dir($webCacheDir)) { @$this->getFilesystem()->mkdirs($webCacheDir); } $this->chmod($webCacheDir, 0777); // note those files that failed if (count($this->opFailed)) { if ('prod' === $options['env']) { $this->logBlock(array('Permissions on some files could not be fixed.', 'You may fix this problem for accessing "/pc_backend.php/sns/cache" via your web browser.', '', 'If you want to get more information, please execute "./symfony openpne:permission --env=dev".'), 'INFO_LARGE'); } else { $this->logBlock(array_merge(array('Permissions on the following file(s) could not be fixed:', ''), array_map(create_function('$f', 'return \' - \'.sfDebug::shortenFilePath($f);'), $this->opFailed)), 'ERROR_LARGE'); } } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $this->logSection('diem', 'Check file permissions'); parent::execute(); $this->current = null; $this->failed = array(); $dirs = array(sfConfig::get('sf_apps_dir'), sfConfig::get('sf_lib_dir'), sfConfig::get('sf_data_dir')); $dirFinder = sfFinder::type('dir'); $fileFinder = sfFinder::type('file'); foreach ($dirs as $dir) { $this->chmod($dirFinder->in($dir), 0777); $this->chmod($fileFinder->in($dir), 0666); } // note those files that failed if (count($this->failed)) { $this->logBlock(array_merge(array('Permissions on the following file(s) could not be fixed:', ''), array_map(create_function('$f', 'return \' - \'.sfDebug::shortenFilePath($f);'), $this->failed)), 'ERROR_LARGE'); } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $this->logSection('Diem Extended', 'Check file permissions'); parent::execute(); $this->chmod(dmOs::join(sfConfig::get('sf_web_dir'), 'cache'), 0777); $this->current = null; $this->failed = array(); $dirs = array(sfConfig::get('sf_apps_dir'), sfConfig::get('sf_lib_dir'), sfConfig::get('sf_data_dir'), sfConfig::get('sf_data_dir'), dmOs::join(sfConfig::get('sf_web_dir'), 'cache')); $dirFinder = sfFinder::type('dir'); $fileFinder = sfFinder::type('file'); foreach ($dirs as $dir) { $this->chmod($dirFinder->in($dir), 0777); $this->chmod($fileFinder->in($dir), 0666); } if (file_exists($dataBin = dmOs::join(sfConfig::get('sf_data_dir'), 'bin'))) { $this->logSection('Diem Extended', 'setting execute bit for user and group to data/bin files'); $this->chmod($fileFinder->in($dataBin), 0770); } // note those files that failed if (count($this->failed)) { $this->logBlock(array_merge(array('Permissions on the following file(s) could not be fixed:', ''), array_map(create_function('$f', 'return \' - \'.sfDebug::shortenFilePath($f);'), $this->failed)), 'ERROR_LARGE'); } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $app = $arguments['app']; // Validate the application name if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $app)) { throw new sfCommandException(sprintf('The application name "%s" is invalid.', $app)); } $appDir = sfConfig::get('sf_apps_dir') . '/' . $app; if (is_dir($appDir)) { throw new sfCommandException(sprintf('The application "%s" already exists.', $appDir)); } if (is_readable(sfConfig::get('sf_data_dir') . '/skeleton/app')) { $skeletonDir = sfConfig::get('sf_data_dir') . '/skeleton/app'; } else { $skeletonDir = __DIR__ . '/skeleton/app'; } // Create basic application structure $finder = sfFinder::type('any')->discard('.sf'); $this->getFilesystem()->mirror($skeletonDir . '/app', $appDir, $finder); // Create $app.php or index.php if it is our first app $indexName = 'index'; $firstApp = !file_exists(sfConfig::get('sf_web_dir') . '/index.php'); if (!$firstApp) { $indexName = $app; } if (true === $options['csrf-secret']) { $options['csrf-secret'] = sha1(mt_rand(11111111, 99999999) . getmypid()); } // Set no_script_name value in settings.yml for production environment $finder = sfFinder::type('file')->name('settings.yml'); $this->getFilesystem()->replaceTokens($finder->in($appDir . '/config'), '##', '##', array('NO_SCRIPT_NAME' => $firstApp ? 'true' : 'false', 'CSRF_SECRET' => sfYamlInline::dump(sfYamlInline::parseScalar($options['csrf-secret'])), 'ESCAPING_STRATEGY' => sfYamlInline::dump((bool) sfYamlInline::parseScalar($options['escaping-strategy'])), 'USE_DATABASE' => sfConfig::has('sf_orm') ? 'true' : 'false')); $this->getFilesystem()->copy($skeletonDir . '/web/index.php', sfConfig::get('sf_web_dir') . '/' . $indexName . '.php'); $this->getFilesystem()->copy($skeletonDir . '/web/index.php', sfConfig::get('sf_web_dir') . '/' . $app . '_dev.php'); $this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir') . '/' . $indexName . '.php', '##', '##', array('APP_NAME' => $app, 'ENVIRONMENT' => 'prod', 'IS_DEBUG' => 'false', 'IP_CHECK' => '')); $this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir') . '/' . $app . '_dev.php', '##', '##', array('APP_NAME' => $app, 'ENVIRONMENT' => 'dev', 'IS_DEBUG' => 'true', 'IP_CHECK' => '// this check prevents access to debug front controllers that are deployed by accident to production servers.' . PHP_EOL . '// feel free to remove this, extend it or make something more sophisticated.' . PHP_EOL . 'if (!in_array(@$_SERVER[\'REMOTE_ADDR\'], array(\'127.0.0.1\', \'::1\')))' . PHP_EOL . '{' . PHP_EOL . ' die(\'You are not allowed to access this file. Check \'.basename(__FILE__).\' for more information.\');' . PHP_EOL . '}' . PHP_EOL)); $this->getFilesystem()->rename($appDir . '/config/ApplicationConfiguration.class.php', $appDir . '/config/' . $app . 'Configuration.class.php'); $this->getFilesystem()->replaceTokens($appDir . '/config/' . $app . 'Configuration.class.php', '##', '##', array('APP_NAME' => $app)); $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); $fixPerms->setConfiguration($this->configuration); $fixPerms->run(); // Create test dir $this->getFilesystem()->mkdirs(sfConfig::get('sf_test_dir') . '/functional/' . $app); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (file_exists('symfony')) { throw new sfCommandException(sprintf('A symfony project already exists in this directory (%s).', getcwd())); } if (!in_array(strtolower($options['orm']), array('propel', 'doctrine', 'none'))) { throw new InvalidArgumentException(sprintf('Invalid ORM name "%s".', $options['orm'])); } if ($options['installer'] && $this->commandApplication && !file_exists($options['installer'])) { throw new InvalidArgumentException(sprintf('The installer "%s" does not exist.', $options['installer'])); } // clean orm option $options['orm'] = ucfirst(strtolower($options['orm'])); $this->arguments = $arguments; $this->options = $options; // create basic project structure $this->installDir(dirname(__FILE__) . '/skeleton/project'); // update ProjectConfiguration class (use a relative path when the symfony core is nested within the project) $symfonyCoreAutoload = 0 === strpos(sfConfig::get('sf_symfony_lib_dir'), sfConfig::get('sf_root_dir')) ? sprintf('dirname(__FILE__).\'/..%s/autoload/sfCoreAutoload.class.php\'', str_replace(sfConfig::get('sf_root_dir'), '', sfConfig::get('sf_symfony_lib_dir'))) : var_export(sfConfig::get('sf_symfony_lib_dir') . '/autoload/sfCoreAutoload.class.php', true); $this->replaceTokens(array(sfConfig::get('sf_config_dir')), array('SYMFONY_CORE_AUTOLOAD' => $symfonyCoreAutoload)); $this->tokens = array('ORM' => $this->options['orm'], 'PROJECT_NAME' => $this->arguments['name'], 'AUTHOR_NAME' => $this->arguments['author'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir')); $this->replaceTokens(); // execute the choosen ORM installer script if (in_array($options['orm'], array('Doctrine', 'Propel'))) { include dirname(__FILE__) . '/../../plugins/sf' . $options['orm'] . 'Plugin/config/installer.php'; } // execute a custom installer if ($options['installer'] && $this->commandApplication) { if ($this->canRunInstaller($options['installer'])) { $this->reloadTasks(); include $options['installer']; } } // fix permission for common directories $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); $fixPerms->setConfiguration($this->configuration); $fixPerms->run(); $this->replaceTokens(); }
if (count($cultures) > 0) { $this->logSection('i18n', 'enabling i18n in Sympal with cultures: ' . implode(', ', $cultures)); $command = sprintf('%s "%s" %s', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir') . '/symfony', 'sympal:configure ' . sprintf('i18n=true language_codes="[%s]"', implode(',', $cultures))); $this->logBlock($command, 'INFO'); $this->getFilesystem()->execute($command, $out, $err); $this->logSection('i18n', sprintf('enabling i18n in application "%s"', $application)); $settingsFilename = sfConfig::get('sf_apps_dir') . '/' . $application . '/config/settings.yml'; $settings = file_get_contents($settingsFilename); $settings .= <<<EOF i18n: true default_culture: {$cultures[0]} EOF; file_put_contents($settingsFilename, $settings); } // execute sympal installation $command = sprintf('%s "%s" %s', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir') . '/symfony', 'sympal:install ' . $application . ' --force-reinstall --email-address="' . $emailAddress . '" --username="******" --password="******" --no-confirmation --db-dsn="' . $db['dsn'] . '" --db-username="******" --db-password="******" --first-name="' . $firstName . '" --last-name="' . $lastName . '"'); $this->logBlock($command, 'INFO'); $this->getFilesystem()->execute($command); // fix permission for common directories $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); $fixPerms->setConfiguration($this->configuration); $fixPerms->run(); $this->replaceTokens(); $this->log(null); $this->logSection('sympal', sprintf('Sympal was installed successfully...', $application)); $url = 'http://localhost/' . $application . '_dev.php/security/signin'; $this->logSection('sympal', sprintf('Open your browser to "%s"', $url)); $this->logSection('sympal', sprintf('You can signin with the username "%s" and password "%s"', $username, $password)); exit;