这是我的目录结构(这只是一个测试项目):
stan@mypc:/generate_assets$ sudo tree -L 3 -p
.
??? [drwxr-xr-x] assets
? ??? [drwxr-xr-x] css
? ??? [-rw-r--r--] test1.css
? ??? [-rw-r--r--] test2.css
??? [-rw-r--r--] composer.json
??? [-rw-r--r--] composer.lock
??? [drwxrwxrwx] public
??? [-rwxr-xr-x] run
??? [drwxr-xr-x] vendor
....skipping...
Run Code Online (Sandbox Code Playgroud)
这是我应该生成资产的简单脚本('run'文件):
#!/usr/bin/env php
<?php
//loading composer's autoload
chdir(__DIR__);
if (file_exists('vendor/autoload.php')) {
include 'vendor/autoload.php';
}
use Assetic\Asset\AssetCollection;
use Assetic\Factory\AssetFactory;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
use Assetic\Filter\LessFilter;
use Assetic\Filter\CssMinFilter;
use Assetic\AssetWriter;
use Assetic\AssetManager;
//Asset manager
$am = new AssetManager();
//Add all css files
$css …Run Code Online (Sandbox Code Playgroud)