sfOptimizerPlugin - 1.0.2

Optimizes cache for production environment.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source | Show as Markdown

sfOptimizerPlugin plugin

The sfOptimizerPlugin tries to optimize your cache files for production environment.

Installation

To install the plugin for a symfony project, the usual process is to use the symfony command line:

$ symfony plugin-install http://plugins.symfony-project.com/sfOptimizerPlugin

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.

Clear the cache to enable the autoloading to find the new classes:

$ php symfony cc

You're done.

What the plugin does

The plugin optimizes the code of a symfony application using various strategies:

  • 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.

    // it replaces blocks such as if (sfConfig::get('sf_logging_enabled')) { // do things } // by if (false) { // do things }

  • It looks for obvious tests and removes the test or the whole block based on the condition value.

    // it replaces blocks such as if (true) { // do things } // by // do things

    // and removes blocks such as if (false) { // do things }

  • It removes comments and whitespace in PHP code, which accelerates the parsing.

You can extend the sfOptimizerPlugin to add other optimization strategies. See the code for more information.

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 Performance Chapter of the symfony Guide for more details).

Usage

The optimization concerns one application in one environment at a time. To launch an optimization, use the new optimize CLI task, as follows:

$ php symfony optimize [[ENVIRONMENT](APPLICATION])

For instance:

$ php symfony optimize frontend prod

Changelog

2007-05-18 | 1.0.2 Stable

  • francois: fixed parameter name in sfConstantOptimizer
  • francois: wrote README