Development

Changeset 4039

You must first sign up to be able to contribute.

Changeset 4039

Show
Ignore:
Timestamp:
05/18/07 18:21:12 (6 years ago)
Author:
francois
Message:

sfOptimizerPlugin: improved README

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfOptimizerPlugin/README

    r2475 r4039  
    55== Installation == 
    66 
    7   * Install the plugin 
    8    
    9     {{{ 
    10       symfony plugin-install http://plugins.symfony-project.com/sfOptimizerPlugin 
    11     }}} 
     7To 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}}} 
    1211 
    13   * Clear symfony cache: 
     12Alternatively, 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.  
    1413 
    15     {{{ 
    16       symfony cc 
    17     }}} 
     14Clear the cache to enable the autoloading to find the new classes: 
     15{{{ 
     16$ php symfony cc 
     17}}} 
    1818 
    19   * Launch the `optimize` task: 
     19You're done. 
    2020 
    21     {{{ 
    22       symfony optimize frontend prod 
    23     }}} 
     21== What the plugin does == 
     22 
     23The 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 
     29if (sfConfig::get('sf_logging_enabled')) 
     30
     31  // do things 
     32
     33// by 
     34if (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 
     44if (true) 
     45
     46  // do things 
     47
     48// by 
     49  // do things 
     50 
     51// and removes blocks such as 
     52if (false) 
     53
     54  // do things 
     55
     56}}} 
     57 
     58 - It removes comments and whitespace in PHP code, which accelerates the parsing. 
     59  
     60You can extend the `sfOptimizerPlugin` to add other optimization strategies. See the code for more information. 
     61 
     62The 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 
     66The 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 
     71For 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  
    3636    throw new Exception('Unable to optimize your config files'); 
    3737  } 
    38  
     38   
     39  pake_echo_action('optimize', "optimizing application $app in environment $env"); 
    3940  $o = new sfOptimizer(); 
    4041  $o->initialize(file_get_contents($config)); 
  • plugins/sfOptimizerPlugin/lib/sfConstantOptimizer.class.php

    r2475 r4039  
    88 
    99    // 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) 
    1111    { 
    1212      $source = str_replace(sprintf('sfConfig::get(\'%s\')', $key), sfConfig::get($key) ? 1 : 0, $source); 
  • plugins/sfOptimizerPlugin/package.xml

    r2858 r4039  
    1111  <active>yes</active> 
    1212 </lead> 
    13  <date>2006-11-29</date> 
     13 <date>2007-05-18</date> 
    1414 <version> 
    15    <release>1.0.1</release> 
     15   <release>1.0.2</release> 
    1616   <api>1.0.0</api> 
    1717 </version> 
     
    5656    <min>1.0.0</min> 
    5757    <max>1.1.0</max> 
    58     <exclude>1.1.0</exclude> 
    5958   </package> 
    6059  </required>