/** * @author Julien Muetton * @see http://www.symfony-project.org/blog/2009/06/10/new-in-symfony-1-3-project-creation-customization */ $fs = new sfFilesystem(); $this->logSection('install', 'default to propel'); $this->logSection('install', 'default to sqlite'); $this->runTask('configure:database', sprintf("'sqlite:%s/propel.db'", sfConfig::get('sf_data_dir'))); $this->logSection('install', 'fix sqlite database permissions'); touch(sfConfig::get('sf_data_dir') . '/propel.db'); chmod(sfConfig::get('sf_data_dir'), 0777); chmod(sfConfig::get('sf_data_dir') . '/propel.db', 0777); $this->logSection('install', 'install propel 1.6'); sfSymfonyPluginManager::disablePlugin('sfPropelPlugin', sfConfig::get('sf_config_dir')); $fs->execute(sprintf('git clone http://github.com/propelorm/sfPropelORMPlugin.git %s/sfPropelORMPlugin', sfConfig::get('sf_plugins_dir'))); $fs->execute(sprintf('cd %s/sfPropelORMPlugin ; git submodule update --init --recursive ; cd -;', sfConfig::get('sf_plugins_dir'))); sfSymfonyPluginManager::enablePlugin('sfPropelORMPlugin', sfConfig::get('sf_config_dir')); $this->logSection('install', 'setup propel behavior'); $ini_file = sfConfig::get('sf_config_dir') . '/propel.ini'; $content = file_get_contents($ini_file); preg_replace('#^propel.behavior#', ';\\1', $content); $content .= <<<EOF propel.behavior.default = symfony,symfony_i18n propel.behavior.symfony.class = plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorSymfony propel.behavior.symfony_i18n.class = plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorI18n propel.behavior.symfony_i18n_translation.class = plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorI18nTranslation propel.behavior.symfony_behaviors.class = plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorSymfonyBehaviors propel.behavior.symfony_timestampable.class = plugins.sfPropel15Plugin.lib.behavior.SfPropelBehaviorTimestampable EOF; file_put_contents($ini_file, $content); $this->runTask('cache:clear');
/** * Enables a plugin in the ProjectConfiguration class. * * @param string $plugin The name of the plugin */ protected function enablePlugin($plugin) { sfSymfonyPluginManager::enablePlugin($plugin, sfConfig::get('sf_config_dir')); }
sfSymfonyPluginManager::enablePlugin('sfDoctrineActAsTaggablePlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('sfTaskExtraPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('sfWebBrowserPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('sfFeed2Plugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('sfSyncContentPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('sfJqueryReloadedPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostrophePlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheBlogPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheExtraSlotsPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheFeedbackPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheImportersPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheMysqlSearchPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheAwesomeLoginPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheCkEditorPlugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostropheHTML5Plugin', sfConfig::get('sf_config_dir')); sfSymfonyPluginManager::enablePlugin('apostrophePeoplePlugin', sfConfig::get('sf_config_dir')); $this->getFilesystem()->execute('git add .; git commit -m "Enabled plugins"'); $this->reloadTasks(); /** * Manipulate the ProjectConfiguration.class.php */ $source = sfClassManipulator::fromFile(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php'); $source->wrapMethod('setup', <<<EOF set_include_path(sfConfig::get('sf_lib_dir') . '/vendor' . PATH_SEPARATOR . get_include_path()); EOF , ""); $source->save(); $this->getFilesystem()->execute('git add .; git commit -m "Added lib/vendor to include path"'); /** * Copy databases.yml */
$username = $this->ask('username (default: root)', 'QUESTION', 'root'); $password = $this->ask('password (default: root)', 'QUESTION', 'root'); $this->runTask('configure:database', sprintf('"mysql:host=%s;dbname=%s" "%s" "%s"', $host, $dbname, $username, $password)); } } else { $this->logBlock('settings', 'use_database set to false'); $settings = sfYaml::load(sfConfig::get('sf_apps_dir') . '/frontend/config/settings.yml'); $settings['all']['.settings']['use_database'] = false; file_put_contents(sfConfig::get('sf_apps_dir') . '/frontend/config/settings.yml', sfYaml::dump($settings, 5)); } $this->getFilesystem()->execute('git add .; git commit -m "initial commit"'); $this->getFilesystem()->execute('git submodule add git://github.com/facebook/facebook-php-sdk.git lib/vendor/facebook-php-sdk'); $this->getFilesystem()->execute('git commit -m \'added facebook-php-sdk subbmodule\''); if ($this->askConfirmation('Do you want to install npAssetsOptimizerPlugin? (default: yes)')) { $this->getFilesystem()->execute('git submodule add git://github.com/n1k0/npAssetsOptimizerPlugin.git plugins/npAssetsOptimizerPlugin'); sfSymfonyPluginManager::enablePlugin('npAssetsOptimizerPlugin', sfConfig::get('sf_config_dir')); $this->getFilesystem()->execute('git add. ;git commit -m \'added npAssetsOptimizerPlugin\''); } $this->runTask('plugin:publish-assets'); /** * Setup a vhost file */ if ($this->askConfirmation('Would you like to generate a vhost config file? (default: yes')) { $this->getFilesystem()->touch(sfConfig::get('sf_config_dir') . '/vhost.dev'); $tmpl = <<<EOF <VirtualHost *:80> ServerName %SERVER_NAME% DocumentRoot "%SF_WEB_DIR%" <Directory "%SF_WEB_DIR%"> AllowOverride All Allow from All
$emailTo = $this->ask('Email address to send errors to? (ie your@email.com)'); $emailFrom = $this->ask('Email should be from what email address? (ie no-reply@example.com)'); // add settings to app.yml updateAppYaml(array('all' => array('sfErrorNotifier' => array('enabled' => 'false', 'emailTo' => $emailTo, 'emailFrom' => $emailFrom, 'emailFormat' => 'html', 'reportPHPErrors' => 'false', 'reportPHPWarnings' => 'false', 'report404' => 'false')), 'prod' => array('sfErrorNotifier' => array('enabled' => 'true')))); sfSymfonyPluginManager::enablePlugin('sfErrorNotifierPlugin', sfConfig::get('sf_config_dir')); $this->getFilesystem()->execute('git add. ;git commit -m "added sfErrorNotifierPlugin"'); } if ($this->askConfirmation('Do you want to install npAssetsOptimizerPlugin? (default: yes)')) { $this->getFilesystem()->execute('git submodule add git://github.com/n1k0/npAssetsOptimizerPlugin.git plugins/npAssetsOptimizerPlugin'); // add settings to app.yml file updateAppYaml(array('all' => array('np_assets_optimizer_plugin' => array('enabled' => 'false', 'class' => 'npAssetsOptimizerService', 'configuration' => array('javascript' => array('enabled' => 'false', 'class' => 'npOptimizerJavascript', 'params' => array('driver' => 'JSMin', 'destination' => '/js/optimized.js', 'timestamp' => 'true', 'files' => array('/js/js.js'))), 'stylesheet' => array('enabled' => 'false', 'class' => 'npOptimizerStylesheet', 'params' => array('driver' => 'Cssmin', 'destination' => '/css/optimized.css', 'timestamp' => 'true', 'files' => array('main.css'))), 'png_image' => array('enabled' => 'false', 'class' => 'npOptimizerPngImage', 'params' => array('driver' => 'Pngout', 'folders' => array('%SF_WEB_DIR%/images'))), 'jpeg_image' => array('enabled' => 'false', 'class' => 'npOptimizerJpegImage', 'params' => array('driver' => 'Jpegtran', 'folders' => array('%SF_WEB_DIR%/images')))))), 'prod' => array('np_assets_optimizer_plugin' => array('enabled' => 'true', 'configuration' => array('javascript' => array('enabled' => 'true'), 'stylesheet' => array('enabled' => 'true'), 'png_image' => array('enabled' => 'false'), 'jpeg_image' => array('enabled' => 'false')))))); $layout = file_get_contents(sfConfig::get('sf_app_template_dir') . '/layout.php'); $layout = preg_replace("/<?php include_stylesheets() ?>/", '<?php include_optimized_stylesheets() ?>', $layout); $layout = preg_replace("/<?php include_javascripts() ?>/", '<?php include_optimized_javascripts() ?>', $layout); file_put_contents(sfConfig::get('sf_app_template_dir') . '/layout.php', $layout); sfSymfonyPluginManager::enablePlugin('sfErrorNotifierPlugin', sfConfig::get('sf_config_dir')); $this->getFilesystem()->execute('git add. ;git commit -m "added npAssetsOptimizerPlugin"'); } /** * publish the plugin assets or make them symlinks son! */ $this->runTask('plugin:publish-assets'); /** * Setup a vhost file */ if ($this->askConfirmation('Would you like to generate a vhost config file? (default: yes')) { $this->getFilesystem()->touch(sfConfig::get('sf_config_dir') . '/vhost.dev'); $tmpl = <<<EOF <VirtualHost *:80> ServerName %SERVER_NAME% DocumentRoot "%SF_WEB_DIR%"