icedream / javascriptpackerbundle
Dean Edwards Packer, usable from Symfony2
Requires
- kriswallsmith/assetic: >=1.1
Suggests
- meenie/javascript-packer: Keep track of the Packer PHP port using Composer
This package is not auto-updated.
Last update: 2020-01-20 03:52:07 UTC
README
This bundle allows you to use the PHP port of Dean Edward's Packer to compress JavaScripts
Beta disclaimer
Feel free to use this bundle but keep in mind it is still in beta stage and needs a bit of testing. If you see any issues with this bundle, please give feedback using the GitHub issue tracker.
Installation/Usage
-
Install via composer:
composer require icedream/javascriptpackerbundle:~1.0@beta
-
Download the PHP port of Dean Edward's packer. The recommended way is to use the suggestion of this package and install
meenie/javascript-packer
via composer.composer require meenie/javascript-packer:~1.1
-
Add bundle to the application kernel (
app/AppKernel.php
):<?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Icedream\JavaScriptPackerBundle\JavaScriptPackerBundle(), ); // ... } }
-
Configure the bundle in
app/config/config.yml
:# Assetic Configuration assetic: filters: jspacker: resource: %kernel.root_dir%/../vendor/icedream/javascriptpackerbundle/Icedream/JavaScriptPackerBundle/Resources/config/services.xml # If you did not use the composer method to download the Packer script, uncomment this and point the variable to the full path of class.JavaScriptPacker.php #packer: %kernel.root_dir%/../vendor/meenie/javascript-packer/class.JavaScriptPacker.php
-
Now you can use the filter as needed.
{% javascripts '@AcmeDemoBundle/Resources/public/js/somescript.js' filter='jspacker' %} <script type="text/javascript" src="{{ asset_url }}"></script> {% endjavascripts %}
License
This bundle is licensed under the MIT license. See LICENSE.txt for more information.