我们想使用asset,特别是管理我们的图像资产。然而,我一直在试图弄清楚如何将资产与我们使用的框架集成,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);
这在逐文件的基础上工作得很好。但是,我想知道是否有一个更好的快捷方式来自动读取我的图像文件,并从所有这些文件中创建单独的资产。
你可以这样使用Glob资产:
use Assetic'Asset'AssetCollection;
use Assetic'Asset'GlobAsset;
$js = new AssetCollection(array(
new GlobAsset('/path/to/js/*')
));