Changeset 10232
- Timestamp:
- 07/11/08 22:12:28 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfGenerateControllerTaskPlugin/trunk/README
r10195 r10232 35 35 }}} 36 36 37 The controller can be configured to listen to the server for configuration variables using the `check-server` option: 38 39 {{{ 40 $ ./symfony generate:controller frontend prod --check-server 41 }}} 42 43 This option will add logic to your controller to first look for `SF_APPLICATION`, `SF_ENVIRONMENT` and `SF_DEBUG` keys in the `$_SERVER` array. If these keys are not found, the command arguments are used as fallback values. 44 45 Using the `check-server` option you can create an `index.php` controller that can dispatch any application, depending on what `SetEnv` directives exist in the requested `VirtualHost` configuration. This feature is Apache-specific. 46 47 {{{ 48 $ ./symfony generate:controller frontend prod --filename="index" --check-server --force 49 }}} 50 37 51 == Changelog == 52 53 === 1.1.0-DEV === 54 55 * Added option to check server for configuration values 56 * Added exception if file already exists and `force` option to overwrite 38 57 39 58 === 1.0.0 === plugins/sfGenerateControllerTaskPlugin/trunk/lib/task/sfGenerateControllerTask.class.php
r10193 r10232 25 25 new sfCommandOption('debug', null, sfCommandOption::PARAMETER_NONE, 'Controller debug mode'), 26 26 new sfCommandOption('allowed-ip', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'Restrict traffic by IP address'), 27 new sfCommandOption('check-server', null, sfCommandOption::PARAMETER_NONE, 'Check for configuration variables in the $_SERVER array'), 28 new sfCommandOption('force', null, sfCommandOption::PARAMETER_NONE, 'Overwrite any existing file of the same name'), 27 29 )); 28 30 … … 37 39 directory: 38 40 39 [./symfony generate:controller frontend dev |INFO]41 [./symfony generate:controller frontend dev --debug|INFO] 40 42 41 43 Traffic to this controller can be restricted by IP address by using the 42 44 [allowed-ip|COMMENT] option: 43 45 44 [./symfony generate:controller frontend dev --allowed-ip="127.0.0.1" |INFO]46 [./symfony generate:controller frontend dev --allowed-ip="127.0.0.1" --debug|INFO] 45 47 46 48 This common use case can also be accomplished using the [localhost|COMMENT] shortcut: 47 49 48 [./symfony generate:controller frontend dev --allowed-ip="localhost" |INFO]50 [./symfony generate:controller frontend dev --allowed-ip="localhost" --debug|INFO] 49 51 50 52 If you want to use a filename other than the symfony default filename, use 51 53 the [filename|COMMENT] option: 52 54 53 [./symfony generate:controller frontend dev --filename="index"|INFO] 55 [./symfony generate:controller frontend prod --filename="index"|INFO] 56 57 The controller can be configured to listen to the server for configuration 58 variables using the [check-server|COMMENT] option: 59 60 [./symfony generate:controller frontend prod --check-server|INFO] 61 62 This option will add logic to your controller to first look for 63 [SF_APPLICATION|COMMENT], [SF_ENVIRONMENT|COMMENT] and [SF_DEBUG|COMMENT] keys in the [\$ SERVER|COMMENT] array. If 64 these keys are not found, the command arguments are used as fallback values. 65 66 Using the [check-server|COMMENT] option you can create an [index.php|COMMENT] controller that can 67 dispatch any application, depending on what [SetEnv|COMMENT] directives exist in the 68 requested [VirtualHost|COMMENT] configuration. This feature is Apache-specific. 69 70 [./symfony generate:controller frontend prod --filename="index" --check-server --force|INFO] 54 71 55 72 EOF; … … 106 123 } 107 124 125 if (file_exists(sfConfig::get('sf_web_dir').'/'.$filename)) 126 { 127 if (isset($options['force']) && $options['force']) 128 { 129 $this->getFilesystem()->remove(sfConfig::get('sf_web_dir').'/'.$filename); 130 } 131 else 132 { 133 throw new InvalidArgumentException(sprintf('A "%s" controller already exists. Use the --force option to overwrite.', $filename)); 134 } 135 } 136 108 137 $this->getFilesystem()->copy(dirname(__FILE__).'/skeleton/index.php', sfConfig::get('sf_web_dir').'/'.$filename); 109 $this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir').'/'.$filename, '##', '##', array( 110 'APP_NAME' => $app, 111 'ENVIRONMENT' => $env, 112 'IS_DEBUG' => isset($options['debug']) && $options['debug'] ? 'true' : 'false', 113 'IP_CHECK' => $ipCheck, 114 )); 138 if (isset($options['check-server']) && $options['check-server']) 139 { 140 $this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir').'/'.$filename, '##', '##', array( 141 'APP_NAME' => "\n ".'isset($_SERVER[\'SF_APPLICATION\']) ? $_SERVER[\'SF_APPLICATION\'] : '.var_export($app, true), 142 'ENVIRONMENT' => "\n ".'isset($_SERVER[\'SF_ENVIRONMENT\']) ? $_SERVER[\'SF_ENVIRONMENT\'] : '.var_export($env, true), 143 'IS_DEBUG' => "\n ".'isset($_SERVER[\'SF_DEBUG\']) ? (boolean) $_SERVER[\'SF_DEBUG\'] : '.(isset($options['debug']) && $options['debug'] ? 'true' : 'false'), 144 'IP_CHECK' => $ipCheck, 145 )); 146 } 147 else 148 { 149 $this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir').'/'.$filename, '##', '##', array( 150 'APP_NAME' => var_export($app, true), 151 'ENVIRONMENT' => var_export($env, true), 152 'IS_DEBUG' => isset($options['debug']) && $options['debug'] ? 'true' : 'false', 153 'IP_CHECK' => $ipCheck, 154 )); 155 } 115 156 } 116 157 plugins/sfGenerateControllerTaskPlugin/trunk/lib/task/skeleton/index.php
r10194 r10232 3 3 require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); 4 4 5 $configuration = ProjectConfiguration::getApplicationConfiguration( '##APP_NAME##', '##ENVIRONMENT##', ##IS_DEBUG##);5 $configuration = ProjectConfiguration::getApplicationConfiguration(##APP_NAME##, ##ENVIRONMENT##, ##IS_DEBUG##); 6 6 sfContext::createInstance($configuration)->dispatch();