我们想使用 Assets ,专门管理我们的图像 Assets 。但是,我一直在努力弄清楚如何将 assetic 与我们使用的框架 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);
这在逐个文件的基础上非常有效。但是,我想知道是否有更好的快捷方式来自动读取我的图像文件并从所有这些文件中创建单独的 Assets 。
最佳答案
您可以像这样使用 Glob Assets :
use Assetic\Asset\AssetCollection;
use Assetic\Asset\GlobAsset;
$js = new AssetCollection(array(
new GlobAsset('/path/to/js/*')
));
关于php - 在 Symfony2 之外使用 assetic(使用 Yii),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16595462/