Changeset 4039
- Timestamp:
- 05/18/07 18:21:12 (6 years ago)
- Files:
-
- plugins/sfOptimizerPlugin/README (modified) (1 diff)
- plugins/sfOptimizerPlugin/data/tasks/sfOptimizerTask.php (modified) (1 diff)
- plugins/sfOptimizerPlugin/lib/sfConstantOptimizer.class.php (modified) (1 diff)
- plugins/sfOptimizerPlugin/package.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfOptimizerPlugin/README
r2475 r4039 5 5 == Installation == 6 6 7 * Install the plugin 8 9 {{{ 10 symfony plugin-install http://plugins.symfony-project.com/sfOptimizerPlugin 11 }}} 7 To install the plugin for a symfony project, the usual process is to use the symfony command line: 8 {{{ 9 $ symfony plugin-install http://plugins.symfony-project.com/sfOptimizerPlugin 10 }}} 12 11 13 * Clear symfony cache: 12 Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's wiki page and extract it under your project's `plugins/` directory. 14 13 15 {{{ 16 symfony cc 17 }}} 14 Clear the cache to enable the autoloading to find the new classes: 15 {{{ 16 $ php symfony cc 17 }}} 18 18 19 * Launch the `optimize` task: 19 You're done. 20 20 21 {{{ 22 symfony optimize frontend prod 23 }}} 21 == What the plugin does == 22 23 The plugin optimizes the code of a symfony application using various strategies: 24 25 - It looks in the code for tests based on symfony configuration that cannot change at runtime, and replaces the call to sfConfig::get() by the actual configuration value. 26 27 {{{ 28 // it replaces blocks such as 29 if (sfConfig::get('sf_logging_enabled')) 30 { 31 // do things 32 } 33 // by 34 if (false) 35 { 36 // do things 37 } 38 }}} 39 40 - It looks for obvious tests and removes the test or the whole block based on the condition value. 41 42 {{{ 43 // it replaces blocks such as 44 if (true) 45 { 46 // do things 47 } 48 // by 49 // do things 50 51 // and removes blocks such as 52 if (false) 53 { 54 // do things 55 } 56 }}} 57 58 - It removes comments and whitespace in PHP code, which accelerates the parsing. 59 60 You can extend the `sfOptimizerPlugin` to add other optimization strategies. See the code for more information. 61 62 The code concerned by the optimization is the one included in the `core_compile.yml` configuration file. By default, this code contains only files from the symfony libraries, but you can add files from your application to the core compile to have them optimized as well (see the [http://www.symfony-project.com/book/trunk/18-Performance#Core%20Compilation Performance Chapter] of the symfony Guide for more details). 63 64 == Usage == 65 66 The optimization concerns one application in one environment at a time. To launch an optimization, use the new `optimize` CLI task, as follows: 67 {{{ 68 $ php symfony optimize [APPLICATION] [ENVIRONMENT] 69 }}} 70 71 For instance: 72 {{{ 73 $ php symfony optimize frontend prod 74 }}} 75 76 == Changelog == 77 78 === 2007-05-18 | 1.0.2 Stable === 79 80 * francois: fixed parameter name in `sfConstantOptimizer` 81 * francois: wrote README plugins/sfOptimizerPlugin/data/tasks/sfOptimizerTask.php
r2475 r4039 36 36 throw new Exception('Unable to optimize your config files'); 37 37 } 38 38 39 pake_echo_action('optimize', "optimizing application $app in environment $env"); 39 40 $o = new sfOptimizer(); 40 41 $o->initialize(file_get_contents($config)); plugins/sfOptimizerPlugin/lib/sfConstantOptimizer.class.php
r2475 r4039 8 8 9 9 // booleans 10 foreach (array('sf_debug', 'sf_test', 'sf_logging_ active', 'sf_web_debug', 'sf_cache', 'sf_i18n') as $key)10 foreach (array('sf_debug', 'sf_test', 'sf_logging_enabled', 'sf_web_debug', 'sf_cache', 'sf_i18n') as $key) 11 11 { 12 12 $source = str_replace(sprintf('sfConfig::get(\'%s\')', $key), sfConfig::get($key) ? 1 : 0, $source); plugins/sfOptimizerPlugin/package.xml
r2858 r4039 11 11 <active>yes</active> 12 12 </lead> 13 <date>200 6-11-29</date>13 <date>2007-05-18</date> 14 14 <version> 15 <release>1.0. 1</release>15 <release>1.0.2</release> 16 16 <api>1.0.0</api> 17 17 </version> … … 56 56 <min>1.0.0</min> 57 57 <max>1.1.0</max> 58 <exclude>1.1.0</exclude>59 58 </package> 60 59 </required>