swCombinePlugin
1.3.0beta
for sf 1.4sf 1.3sf 1.2 MIT
PLEASE NOTE : THE SYMFONY REPOSITORY IS NOT USED ANYMORE, PLEASE USE THE ONE ON GITHUB : http://github.com/rande/swCombinePlugin
swCombinePlugin
This plugin combines javascript and stylesheet files into optimized files.
How it works ?
The plugin read all view.yml files and generates the correct combined files :
Benefits
- Combine files and optimizations are performed when the application is deployed
- The view cache file generates the correct path to the combined files, so there is not computation at runtime.
Developers
| Name |
Status |
Email |
Thomas Rabaix |
lead |
moc.bewoelos <<ta>> xiabar.samoht
|
License
Copyright (c) 2010 Soleoweb SARL - Thomas Rabaix <thomas.rabaix@soleoweb.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Releases for sf 1.4
| Version |
License |
API |
Released |
|
1.3.0beta
|
MIT license |
1.3.0beta
|
28/03/2010 |
Releases for sf 1.3
| Version |
License |
API |
Released |
|
1.3.0beta
|
MIT license |
1.3.0beta
|
28/03/2010 |
Releases for sf 1.2
| Version |
License |
API |
Released |
|
1.3.0beta
|
MIT license |
1.3.0beta
|
28/03/2010 |
Changelog for release 1.3.0 - 28/03/2010
Other releases
Release 1.3.0 - 28/03/2010
swCombinePlugin
This plugin combines javascript and stylesheet files into optimized files.
How it works ?
The plugin read all view.yml files and generates the correct combined files :
The plugin can also generate packages from a list of files. This feature allows you to create a common set of files for your website, and include specific assets for a view.
Benefits
- Combine files and optimizations are performed when the application is deployed
- The view cache file generates the correct path to the combined files, so there is not computation at runtime.
Available optimizers
Global
- swPassDriver : do nothing, use this if you want to combine your files with no optizations
Javascript
- swDriverGoogleClosureCompilerApi : use google closure algorithm
- swDriverJSMin : use JSMin algorithm
- swDriverJSMinPlus : user JSMin+ algorithm
Stylesheet
- swDriverCssmin : use Css min algorithm
- swDriverMinifyCssCompressor : use Minify Css Compressor algorithm
Install
edit ProjectConfiguration.class.php by adding the requirement and enable the plugin
require_once(dirname(__FILE__).'/../plugins/swCombinePlugin/lib/config/swCombineViewConfigHandler.class.php');
class ProjectConfiguration extends ysfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array(
// your plugins
'swCombinePlugin'
));
}
}
edit your app.yml file and add an optional version value
swToolbox:
swCombine:
# the version number can be used to force load of new files from the media server
# you can configure a never ending expired time on your media server
# if the version is never updated, media will be never reloaded ...
version: 3
add a config_handlers.yml inside APP/config
modules/*/config/view.yml:
# put sfViewConfigHandler to restore the default symfony config handler
# class: sfViewConfigHandler
class: swCombineViewConfigHandler
param:
private_path: %SF_WEB_DIR%/sw-combine
public_path: /sw-combine
configuration:
javascript:
combine: swCombineJavascript
driver: swDriverJSMinPlus
filename: %s.js # %s will by replace by the combined name
exclude:
- /js/jQuery/jquery.1.2.6.js
- /js/jQuery/ui-1.5.3/jquery.ui.all.js
- /js/jQuery/offset.js
- /js/jQuery/jquery.form-defaults.js
- /js/jQuery/jquery.timers-1.2.js
- /js/jqModal/jqModal.js
- /js/scrollTo/jquery.scrollTo-min.js
- /js/main.js
packages:
common:
auto_include: true
files:
- /js/jQuery/jquery.1.2.6.js
- /js/jQuery/ui-1.5.3/jquery.ui.all.js
- /js/jQuery/offset.js
- /js/jQuery/jquery.form-defaults.js
- /js/jQuery/jquery.timers-1.2.js
- /js/jqModal/jqModal.js
- /js/scrollTo/jquery.scrollTo-min.js
- /js/main.js
stylesheet:
combine: swCombineStylesheet
driver: swDriverCssmin
filename: %s.css # %s will by replace by the combined name
exclude:
- /css/main.css
- /css/draft/ui-theme.css
- /css/mg-theme.css
- /css/print.css
packages:
common:
auto_include: true
files:
- /css/main.css
- /css/draft/ui-theme.css
- /css/mg-theme.css
clear your cache
./symfony cc
combine css and js with
./symfony sw:combine frontend
./symfony sw:combine backend
Assets version (optional)
This plugin has a hidden gem : asset versioning. When css files are combined, a version number is added to all externals references. This feature must be use with helper functions sw_include_stylesheets() and sw_include_javascripts(), this two helpers add the version number on each declared assets.
The asset version format is : ASSET_FILE?_sw=ASSET_VERSION
What does it mean ?
You can configure a long time expired value on your server by using simple regular expression.
(.*)\?_sw=(.*) => expired in 1 month.
Doing so, the user agent will not do any extras requests to the webserver.
Defining the asset version
edit your app.yml file by adding these lines
swToolbox:
swCombine:
version: 42
clear your cache
./symfony cc
regenerate the combined css and js files with
./symfony sw:combine frontend
./symfony sw:combine backend