【问题标题】:Using assetic outside Symfony2 (with Yii)在 Symfony2 之外使用资产(使用 Yii)
【发布时间】:2013-05-16 19:07:03
【问题描述】:

我们想使用资产,专门用于管理我们的图像资产。但是,我一直在试图弄清楚如何将资产与我们使用的框架 Yii 集成。

我要做的是读取位于 /assets/images 中的图像并将它们写入文件夹 /public/images

这是我目前正在做的事情:

$am = new AssetManager();

$image = new FileAsset(__DIR__ . '/../../assets/images/bg-arrow.png');
$image->setTargetPath('/images/bg-arrow.jpg');

$am->set('ambassadors',$image);

$writer = new AssetWriter(__DIR__ . '/../../public');
$writer->writeManagerAssets($am);

这在逐个文件的基础上非常有效。但是,我想知道是否有更好的快捷方式来自动读取我的图像文件并从所有这些文件中创建单独的资产。

【问题讨论】:

标签: php yii assetic


【解决方案1】:

您可以像这样使用 Glob 资源:

use Assetic\Asset\AssetCollection;
use Assetic\Asset\GlobAsset;

$js = new AssetCollection(array(
    new GlobAsset('/path/to/js/*')
));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-06
    • 1970-01-01
    • 2014-08-02
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    相关资源
    最近更新 更多