shineunited / silex-assets
2.0.0
2017-05-17 20:43 UTC
Requires
- php: >=5.5.9
- silex/silex: ^2.0
Requires (Dev)
- phpunit/phpunit: ~4.0|~5.0
- symfony/browser-kit: ~3.0
- twig/twig: ^1.33
Suggests
- twig/twig: Allow use of asset manager inside of twig templates
This package is auto-updated.
Last update: 2024-09-15 01:30:22 UTC
README
一个用于管理本地和远程静态资源的Silex包。
安装
推荐通过composer安装silex-assets
$ composer require shineunited/silex-assets
配置
require_once(__DIR__ . '/../vendor.autoload.php'); use Silex\Application; use ShineUnited\Silex\Assets\AssetManagerServiceProvider; $app->register(new AssetManagerServiceProvider(), [ 'assets.path' => '/path/to/assets/' ]);
用法
访问前缀资源
echo $app['assets']->lookup('my/asset.txt'); // returns: /path/to/assets/my/asset.txt
映射额外资源
$app['assets']->map('jquery.js', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'); echo $app['assets']->lookup('jquery.js'); // returns: https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js