saxulum / saxulum-assetic-twig-provider
此软件包已被 弃用 并不再维护。没有建议的替代软件包。
Saxulum Assetic Twig Provider
2.0.5
2015-12-01 11:51 UTC
Requires
- php: >=5.3.3,<8.0
- kriswallsmith/assetic: ~1.2
- pimple/pimple: >=2.1,<4
- symfony/finder: ~2.3|~3.0
- symfony/http-foundation: ~2.3|~3.0
- twig/twig: ~1.2
Requires (Dev)
- cssmin/cssmin: ~3.0.1
- leafo/scssphp: v0.4
- mrclay/minify: ~2.2.0
- oyejorge/less.php: ~1.7
- phpunit/phpunit: ~4.1
- psr/log: ~1.0
- silex/api: ~2.0@dev
- silex/providers: ~2.0@dev
Suggests
- cssmin/cssmin: ~3.0.1
- leafo/scssphp: v0.4
- mrclay/minify: ~2.2.0
- oyejorge/less.php: ~1.7
- psr/log: ~1.0
- saxulum/saxulum-console: ~3.1
- silex/api: ~2.0@dev
- silex/providers: ~2.0@dev
README
与 plain silex-php 兼容
特性
- 为 Twig 模板添加 Assetic 支持
要求
- PHP 5.3+
- Kriswallsmith 的 Assets 框架 (Assetic) 1.2+
- Symfony Finder 组件 2.3+
- Twig 1.2+
安装
通过 Composer 作为 saxulum/saxulum/saxulum-assetic-twig-provider 安装。
$app->register(new TwigServiceProvider());
$app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem',
function (\Twig_Loader_Filesystem $twigLoaderFilesystem) {
$twigLoaderFilesystem->addPath('/path/to/the/views', 'SomeNamespace');
return $twigLoaderFilesystem;
}
));
$app->register(new AsseticTwigProvider(), array(
'assetic.asset.root' => '/path/to/project/root',
'assetic.asset.asset_root' => '/path/to/asset/root',
));
配置
此过滤器已预配置,默认启用
- csscopyfile
- lessphp
- scssphp
- cssmin
- csscompress
- jsmin
如果您想禁用默认的过滤器
$app['assetic.filters'] = $container->share(
$app->extend('assetic.filters', function ($filters) use ($app) {
$filters['cssmin'] = false;
return $filters;
})
);
如果您想添加更多未预配置的过滤器
$container['assetic.filterinstances'] = $container->share(
$app->extend('assetic.filterinstances', function ($filterInstances) use ($container) {
$filterInstances['jsminplus'] = new JSMinPlusFilter();
return $filterInstances;
})
);
用法
CSS 示例
{% stylesheets
'relative/from/path/to/project/root/*.css'
output='relative/from/path/to/asset/root/css/test.css'
filter='cssmin'
%}
{{ asset_url }}
{% endstylesheets %}
JS 示例
{% javascripts
'relative/from/path/to/project/root/*.js'
output='relative/from/path/to/asset/root/css/test.js'
filter='jsmin'
%}
{{ asset_url }}
{% endjavascripts %}
版权
- Dominik Zogg dominik.zogg@gmail.com