Service provider to support Assetic library for Silex 2.0+ micro-framework.
This project is a part of
silex-tools
library.
You can install silex-assetic
with Composer:
composer require lokhman/silex-assetic
Register AsseticServiceProvider
in your application with the following code:
use Lokhman\Silex\Provider\AsseticServiceProvider;
$app->register(new AsseticServiceProvider());
N.B.: Assetic will always be in debug mode if $app['debug']
is TRUE
.
Configuration is mostly the same as you have for AsseticBundle in Symfony framework.
"assetic.options": {
"prefix": "/",
"input_dir": "src",
"output_dir": "web",
"cache_dir": "cache/assetic",
"twig_functions": [],
"java": "/usr/bin/java",
"ruby": "/usr/bin/ruby",
"node": "/usr/bin/node",
"node_paths": [],
"filters": {
"some_filter": {}
},
"assets": {
"some_asset": {
"inputs": [],
"filters": [],
"options": {}
}
}
}
Filters are defined in FilterFactory
class and mirror names and options of
AsseticBundle.
Twig extension is enabled automatically if you have TwigServiceProvider
registered for the application.
You can use console command with silex-console
service provider simply
adding DumpCommand
to the console application.
use Lokhman\Silex\Console\Console;
use Lokhman\Silex\Console\Command\Assetic\DumpCommand;
$console = new Console($app);
$console->add(new DumpCommand());
$console->run();
For more details please refer to the asset management documentation of Symfony framework.
Library is available under the MIT license. The included LICENSE file describes this in detail.