sfCombinePlugin =============== sfCombinePlugin combines multiple JavaScript and CSS files into grouped JavaScript and CSS files at runtime, in order to minimize the number of HTTP requests required to render a given page. If you want to know why this is essential for your website performance, read [Yahoo's Performance Research Findings](http://yuiblog.com/blog/2006/11/28/performance-research-part-1/). Without sfCombinePlugin, a typical page requires many HTTP requests to get JavaScript and CSS files: [html] ... With sfCombinePlugin, every page needs far fewer HTTP requests for all JavaScript code and style rules: [html] ... The JavaScript and CSS files are now served by a custom action of the `sfCombine` module, which combines and compresses several files into a single one. If another page requires the same combination of files, it will include calls to the `js` and `css` actions of the `sfCombine` module with a similar `key` parameter. Otherwise, the plugin generates a different `key`, so that only the required files are loaded by the new page. `sfCombinePlugin` is optimized and tested to work in professional environments: - The `sfCombine` module uses the symfony cache system to avoid executing the combination and compression routine for every request - HTTP 1.1 caching statements are added to let browsers and proxies keep the combined JavaScript and CSS files in their local cache - The combined files work in distributed environments, where you use several servers for load-balancing - No additional database query is required at runtime when an op-code cache engine (like APC) is available Requirements ------------ This plugin adds one database table, this is not required for usage however. Installation ------------ 1. Download the plugin. The easiest way to download `sfCombinePlugin` is to use the symfony command line: > php symfony plugin:install sfCombinePlugin --release=2.0.0 Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's page and extract it under your project's `plugins/` directory, or use `svn:externals` on your project's `plugins` directory. 2. Rebuild your model. For Doctrine, that means calling the doctrine `doctrine:build-model` task: > php symfony doctrine:build-model This will create a model called `sfCombinePlugin`. For Propel, call the task `propel:build-model`. It will generate a model called `sfCombine`. 3. Create the related `sf_combine` table in your database. Symfony can generate the necessary SQL code for you: > php symfony propel:build-sql Then, depending on your database engine, use the SQL code generated in `data/sql/plugins.sfCombinePlugin.lib.model.schema.sql` to insert the table in the database. For instance, for mySQL: > mysql -u username -p dbname < data/sql/plugins.sfCombinePlugin.lib.model.schema.sql For Doctrine, you need to call this task `doctrine:build-sql`. 4. Enable the `sfCombine` module in your frontend application, via the `settings.yml` file. [yml] # in myproject/apps/frontend/config/settings.yml all: .settings: enabled_modules: [..., sfCombine] 5. Replacing JavaScript and CSS calls in the layout Since symfony 1.3, the layout uses the regular `include_javascripts()` and `include_stylesheets()` helpers to output calls to the JavaScript and CSS files. Replace them with the `include_combined_javascripts()` and the `include_combined_stylesheets()` helpers. They belong to the `sfCombine` helper group, which must be declared prior to calling the helpers: [php] // in apps/frontend/templates/layout.php getRaw('notice') ?> Note that if you use symfony 1.2 you must change the `common` filter class from `sfCommonFilter` to `sfCombineFilter` in your application `filters.yml` (See `Including Javascript And CSS With A Filter` chapter) You sometimes need to change the place where script and CSS inclusion tags appear in the source code. For instance, you may want to move the `