toopay / assetic-minifier
Assetic Filter for pure PHP JS and CSS minification
Installs: 56 284
Dependents: 4
Suggesters: 1
Security: 0
Stars: 12
Watchers: 2
Forks: 4
Open Issues: 1
Requires
- php: >=5.3.3
- kriswallsmith/assetic: ~1.1
Requires (Dev)
- phpunit/phpunit: ~3.7
- symfony/symfony: 2.*
This package is not auto-updated.
Last update: 2024-10-26 15:29:05 UTC
README
Portable Assetic Filter for pure PHP JS and CSS minification.
Symfony2 configuration
Installation
After installing this package with Composer, add the following line to you AppKernel.php
<?php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Minifier\MinifierBundle(),
// ...
);
return $bundles;
}
}
Now add the following bit to your config.yml
minifier:
filter:
name:
css: ~
js: ~
This will provide two Assetic filters named minifier_css
and minifier_js
.
Usage
The filters can now be used like the following
// ::base.html.twig
// ...
{# Minify CSS files #}
{% stylesheets filter='minifier_css' output='css/main.css'
'@AcmeBundle/Resources/public/css/init.css'
%}
<link href="{{ asset_url }}" rel="stylesheet" />
{% endstylesheets %}
// ...
{# Minify JS files #}
{% javascripts filter='minifier_js' output='js/scripts.js'
'@AcmeBundle/Resources/js/scripts.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
Rename the filters
To overwrite the filters names, simply changes them in your config.yml
:
minifier:
filter:
name:
css: myCssMinifierFilterName
js: myJsMinifierFilterName