[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-8481":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":16,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":16,"starSnapshotCount":16,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},8481,"assetic","kriswallsmith\u002Fassetic","kriswallsmith","Asset Management for PHP","",null,"PHP",3717,547,118,217,0,30.22,"MIT License",false,"master",[],"2026-06-12 02:01:54","# Assetic [![Build Status](https:\u002F\u002Ftravis-ci.org\u002Fkriswallsmith\u002Fassetic.png?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Fkriswallsmith\u002Fassetic)\n\nAssetic is an asset management framework for PHP.\n\nProject status\n--------------\n\nThis project is not maintained anymore. Development has been taken over at https:\u002F\u002Fgithub.com\u002Fassetic-php\u002Fassetic under the package name `assetic\u002Fframework`.\n\nExample\n-------\n\n``` php\n\u003C?php\n\nuse Assetic\\Asset\\AssetCollection;\nuse Assetic\\Asset\\FileAsset;\nuse Assetic\\Asset\\GlobAsset;\n\n$js = new AssetCollection(array(\n    new GlobAsset('\u002Fpath\u002Fto\u002Fjs\u002F*'),\n    new FileAsset('\u002Fpath\u002Fto\u002Fanother.js'),\n));\n\n\u002F\u002F the code is merged when the asset is dumped\necho $js->dump();\n```\n\nAssets\n------\n\nAn Assetic asset is something with filterable content that can be loaded and\ndumped. An asset also includes metadata, some of which can be manipulated and\nsome of which is immutable.\n\n| **Property** | **Accessor**    | **Mutator**   |\n|--------------|-----------------|---------------|\n| content      | getContent      | setContent    |\n| mtime        | getLastModified | n\u002Fa           |\n| source root  | getSourceRoot   | n\u002Fa           |\n| source path  | getSourcePath   | n\u002Fa           |\n| target path  | getTargetPath   | setTargetPath |\n\nThe \"target path\" property denotes where an asset (or an collection of assets) should be dumped.\n\nFilters\n-------\n\nFilters can be applied to manipulate assets.\n\n``` php\n\u003C?php\n\nuse Assetic\\Asset\\AssetCollection;\nuse Assetic\\Asset\\FileAsset;\nuse Assetic\\Asset\\GlobAsset;\nuse Assetic\\Filter\\LessFilter;\nuse Assetic\\Filter\\Yui;\n\n$css = new AssetCollection(array(\n    new FileAsset('\u002Fpath\u002Fto\u002Fsrc\u002Fstyles.less', array(new LessFilter())),\n    new GlobAsset('\u002Fpath\u002Fto\u002Fcss\u002F*'),\n), array(\n    new Yui\\CssCompressorFilter('\u002Fpath\u002Fto\u002Fyuicompressor.jar'),\n));\n\n\u002F\u002F this will echo CSS compiled by LESS and compressed by YUI\necho $css->dump();\n```\n\nThe filters applied to the collection will cascade to each asset leaf if you\niterate over it.\n\n``` php\n\u003C?php\n\nforeach ($css as $leaf) {\n    \u002F\u002F each leaf is compressed by YUI\n    echo $leaf->dump();\n}\n```\n\nThe core provides the following filters in the `Assetic\\Filter` namespace:\n\n * `AutoprefixerFilter`: Parse and update vendor-specific properties using autoprefixer\n * `CoffeeScriptFilter`: compiles CoffeeScript into Javascript\n * `CompassFilter`: Compass CSS authoring framework\n * `CssEmbedFilter`: embeds image data in your stylesheets\n * `CssImportFilter`: inlines imported stylesheets\n * `CssMinFilter`: minifies CSS\n * `CleanCssFilter`: minifies CSS\n * `CssRewriteFilter`: fixes relative URLs in CSS assets when moving to a new URL\n * `DartFilter`: compiles Javascript using dart2js\n * `EmberPrecompileFilter`: precompiles Handlebars templates into Javascript for use in the Ember.js framework\n * `GoogleClosure\\CompilerApiFilter`: compiles Javascript using the Google Closure Compiler API\n * `GoogleClosure\\CompilerJarFilter`: compiles Javascript using the Google Closure Compiler JAR\n * `GssFilter`: compliles CSS using the Google Closure Stylesheets Compiler\n * `HandlebarsFilter`: compiles Handlebars templates into Javascript\n * `JpegoptimFilter`: optimize your JPEGs\n * `JpegtranFilter`: optimize your JPEGs\n * `JSMinFilter`: minifies Javascript\n * `JSMinPlusFilter`: minifies Javascript\n * `JSqueezeFilter`: compresses Javascript\n * `LessFilter`: parses LESS into CSS (using less.js with node.js)\n * `LessphpFilter`: parses LESS into CSS (using lessphp)\n * `OptiPngFilter`: optimize your PNGs\n * `PackagerFilter`: parses Javascript for packager tags\n * `PackerFilter`: compresses Javascript using Dean Edwards's Packer\n * `PhpCssEmbedFilter`: embeds image data in your stylesheet\n * `PngoutFilter`: optimize your PNGs\n * `ReactJsxFilter`: compiles React JSX into JavaScript\n * `Sass\\SassFilter`: parses SASS into CSS\n * `Sass\\ScssFilter`: parses SCSS into CSS\n * `SassphpFilter`: parses Sass into CSS using the sassphp bindings for Libsass\n * `ScssphpFilter`: parses SCSS using scssphp\n * `SeparatorFilter`: inserts a separator between assets to prevent merge failures\n * `SprocketsFilter`: Sprockets Javascript dependency management\n * `StylusFilter`: parses STYL into CSS\n * `TypeScriptFilter`: parses TypeScript into Javascript\n * `UglifyCssFilter`: minifies CSS\n * `UglifyJs2Filter`: minifies Javascript\n * `UglifyJsFilter`: minifies Javascript\n * `Yui\\CssCompressorFilter`: compresses CSS using the YUI compressor\n * `Yui\\JsCompressorFilter`: compresses Javascript using the YUI compressor\n\nAsset Manager\n-------------\n\nAn asset manager is provided for organizing assets.\n\n``` php\n\u003C?php\n\nuse Assetic\\AssetManager;\nuse Assetic\\Asset\\FileAsset;\nuse Assetic\\Asset\\GlobAsset;\n\n$am = new AssetManager();\n$am->set('jquery', new FileAsset('\u002Fpath\u002Fto\u002Fjquery.js'));\n$am->set('base_css', new GlobAsset('\u002Fpath\u002Fto\u002Fcss\u002F*'));\n```\n\nThe asset manager can also be used to reference assets to avoid duplication.\n\n``` php\n\u003C?php\n\nuse Assetic\\Asset\\AssetCollection;\nuse Assetic\\Asset\\AssetReference;\nuse Assetic\\Asset\\FileAsset;\n\n$am->set('my_plugin', new AssetCollection(array(\n    new AssetReference($am, 'jquery'),\n    new FileAsset('\u002Fpath\u002Fto\u002Fjquery.plugin.js'),\n)));\n```\n\nFilter Manager\n--------------\n\nA filter manager is also provided for organizing filters.\n\n``` php\n\u003C?php\n\nuse Assetic\\FilterManager;\nuse Assetic\\Filter\\Sass\\SassFilter;\nuse Assetic\\Filter\\Yui;\n\n$fm = new FilterManager();\n$fm->set('sass', new SassFilter('\u002Fpath\u002Fto\u002Fparser\u002Fsass'));\n$fm->set('yui_css', new Yui\\CssCompressorFilter('\u002Fpath\u002Fto\u002Fyuicompressor.jar'));\n```\n\nAsset Factory\n-------------\n\nIf you'd rather not create all these objects by hand, you can use the asset\nfactory, which will do most of the work for you.\n\n``` php\n\u003C?php\n\nuse Assetic\\Factory\\AssetFactory;\n\n$factory = new AssetFactory('\u002Fpath\u002Fto\u002Fasset\u002Fdirectory\u002F');\n$factory->setAssetManager($am);\n$factory->setFilterManager($fm);\n$factory->setDebug(true);\n\n$css = $factory->createAsset(array(\n    '@reset',         \u002F\u002F load the asset manager's \"reset\" asset\n    'css\u002Fsrc\u002F*.scss', \u002F\u002F load every scss files from \"\u002Fpath\u002Fto\u002Fasset\u002Fdirectory\u002Fcss\u002Fsrc\u002F\"\n), array(\n    'scss',           \u002F\u002F filter through the filter manager's \"scss\" filter\n    '?yui_css',       \u002F\u002F don't use this filter in debug mode\n));\n\necho $css->dump();\n```\n\nThe `AssetFactory` is constructed with a root directory which is used as the base directory for relative asset paths.\n\nPrefixing a filter name with a question mark, as `yui_css` is here, will cause\nthat filter to be omitted when the factory is in debug mode.\n\nYou can also register [Workers](src\u002FAssetic\u002FFactory\u002FWorker\u002FWorkerInterface.php) on the factory and all assets created\nby it will be passed to the worker's `process()` method before being returned. See _Cache Busting_ below for an example.\n\nDumping Assets to static files\n------------------------------\n\nYou can dump all the assets an AssetManager holds to files in a directory. This will probably be below your webserver's document root\nso the files can be served statically.\n\n``` php\n\u003C?php\n\nuse Assetic\\AssetWriter;\n\n$writer = new AssetWriter('\u002Fpath\u002Fto\u002Fweb');\n$writer->writeManagerAssets($am);\n```\n\nThis will make use of the assets' target path.\n\nCache Busting\n-------------\n\nIf you serve your assets from static files as just described, you can use the CacheBustingWorker to rewrite the target\npaths for assets. It will insert an identifier before the filename extension that is unique for a particular version\nof the asset.\n\nThis identifier is based on the modification time of the asset and will also take depended-on assets into\nconsideration if the applied filters support it.\n\n``` php\n\u003C?php\n\nuse Assetic\\Factory\\AssetFactory;\nuse Assetic\\Factory\\Worker\\CacheBustingWorker;\n\n$factory = new AssetFactory('\u002Fpath\u002Fto\u002Fasset\u002Fdirectory\u002F');\n$factory->setAssetManager($am);\n$factory->setFilterManager($fm);\n$factory->setDebug(true);\n$factory->addWorker(new CacheBustingWorker());\n\n$css = $factory->createAsset(array(\n    '@reset',         \u002F\u002F load the asset manager's \"reset\" asset\n    'css\u002Fsrc\u002F*.scss', \u002F\u002F load every scss files from \"\u002Fpath\u002Fto\u002Fasset\u002Fdirectory\u002Fcss\u002Fsrc\u002F\"\n), array(\n    'scss',           \u002F\u002F filter through the filter manager's \"scss\" filter\n    '?yui_css',       \u002F\u002F don't use this filter in debug mode\n));\n\necho $css->dump();\n```\n\nInternal caching\n-------\n\nA simple caching mechanism is provided to avoid unnecessary work.\n\n``` php\n\u003C?php\n\nuse Assetic\\Asset\\AssetCache;\nuse Assetic\\Asset\\FileAsset;\nuse Assetic\\Cache\\FilesystemCache;\nuse Assetic\\Filter\\Yui;\n\n$yui = new Yui\\JsCompressorFilter('\u002Fpath\u002Fto\u002Fyuicompressor.jar');\n$js = new AssetCache(\n    new FileAsset('\u002Fpath\u002Fto\u002Fsome.js', array($yui)),\n    new FilesystemCache('\u002Fpath\u002Fto\u002Fcache')\n);\n\n\u002F\u002F the YUI compressor will only run on the first call\n$js->dump();\n$js->dump();\n$js->dump();\n```\n\nTwig\n----\n\nTo use the Assetic [Twig][3] extension you must register it to your Twig\nenvironment:\n\n``` php\n\u003C?php\n\n$twig->addExtension(new AsseticExtension($factory));\n```\n\nOnce in place, the extension exposes a stylesheets and a javascripts tag with a syntax similar\nto what the asset factory uses:\n\n``` html+jinja\n{% stylesheets '\u002Fpath\u002Fto\u002Fsass\u002Fmain.sass' filter='sass,?yui_css' output='css\u002Fall.css' %}\n    \u003Clink href=\"{{ asset_url }}\" type=\"text\u002Fcss\" rel=\"stylesheet\" \u002F>\n{% endstylesheets %}\n```\n\nThis example will render one `link` element on the page that includes a URL\nwhere the filtered asset can be found.\n\nWhen the extension is in debug mode, this same tag will render multiple `link`\nelements, one for each asset referenced by the `css\u002Fsrc\u002F*.sass` glob. The\nspecified filters will still be applied, unless they are marked as optional\nusing the `?` prefix.\n\nThis behavior can also be triggered by setting a `debug` attribute on the tag:\n\n``` html+jinja\n{% stylesheets 'css\u002F*' debug=true %} ... {% stylesheets %}\n```\n\nThese assets need to be written to the web directory so these URLs don't\nreturn 404 errors.\n\n``` php\n\u003C?php\n\nuse Assetic\\AssetWriter;\nuse Assetic\\Extension\\Twig\\TwigFormulaLoader;\nuse Assetic\\Extension\\Twig\\TwigResource;\nuse Assetic\\Factory\\LazyAssetManager;\n\n$am = new LazyAssetManager($factory);\n\n\u002F\u002F enable loading assets from twig templates\n$am->setLoader('twig', new TwigFormulaLoader($twig));\n\n\u002F\u002F loop through all your templates\nforeach ($templates as $template) {\n    $resource = new TwigResource($twigLoader, $template);\n    $am->addResource($resource, 'twig');\n}\n\n$writer = new AssetWriter('\u002Fpath\u002Fto\u002Fweb');\n$writer->writeManagerAssets($am);\n```\n\n---\n\nAssetic is based on the Python [webassets][1] library (available on\n[GitHub][2]).\n\n[1]: http:\u002F\u002Felsdoerfer.name\u002Fdocs\u002Fwebassets\n[2]: https:\u002F\u002Fgithub.com\u002Fmiracle2k\u002Fwebassets\n[3]: http:\u002F\u002Ftwig.sensiolabs.org\n","Assetic 是一个用于 PHP 的资产管理框架。它允许开发者将多种资源文件（如 JavaScript 和 CSS）合并、压缩和处理，从而提高网站性能。其核心功能包括支持多种过滤器来处理不同类型的资源文件，例如通过 LessFilter 编译 LESS 文件或使用 YUI 压缩 CSS。此外，Assetic 提供了灵活的 API 来定义资源集合及其输出路径，便于在开发和生产环境中管理静态资源。尽管该项目已不再维护，但其设计理念和技术实现对于需要高效管理前端资源的 PHP 项目仍然具有参考价值。",2,"2026-06-11 03:18:15","top_language"]