shineunited/silex-assets

2.0.0 2017-05-17 20:43 UTC

This package is auto-updated.

Last update: 2024-09-15 01:30:22 UTC


README

一个用于管理本地和远程静态资源的Silex包。

Latest Stable Version Minimum PHP Version Build Status

安装

推荐通过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