Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Assetic Laravel Package

bonami-cz/assetic

Assetic is a PHP asset management framework for combining, filtering, and dumping assets like JS and CSS. Supports asset collections, file/glob inputs, metadata (target path, mtime), and a wide range of filters for compilation and minification.

View on GitHub
Deep Wiki
Context7

Asset Management for PHP

Frequently asked questions about Assetic
Can I use Assetic in Laravel for CSS/JS bundling instead of Laravel Mix or Vite?
Assetic can replace Laravel Mix/Vite for PHP-based asset processing, but it lacks modern features like HMR or source maps. It’s ideal for legacy Laravel apps without Node.js or dynamic asset generation (e.g., user-uploaded themes). For static assets, Laravel Mix/Vite is still recommended for performance.
How do I install and configure Assetic in a Laravel project?
Install via Composer: `composer require bonami-cz/assetic`. Configure assets in a service provider or facade to bridge Assetic’s `Asset` class with Laravel’s `asset()` helper. Example: Create a facade like `AsseticAsset` to wrap `Asset::create()` calls. No Laravel-specific config files are required.
Does Assetic support Laravel’s Blade directives (e.g., `@asset`)?
No, Assetic doesn’t integrate natively with Blade directives. You’ll need to manually generate asset URLs (e.g., `asset('css/compiled.css')`) or create a custom Blade directive. For dynamic assets, use Assetic’s `Asset::setTargetPath()` to version files (e.g., `?v=123`).
What Laravel versions does Assetic support?
Assetic is framework-agnostic but works with Laravel 5.8+. It requires PHP 7.2+. For Laravel 8/9, test compatibility due to Symfony component updates. No Laravel-specific optimizations exist, so manual integration is required for newer features like Vite’s asset injection.
Can Assetic handle SCSS, TypeScript, or other modern preprocessors?
Assetic supports basic preprocessors like LESS (via `LessFilter`) and CoffeeScript (`CoffeeScriptFilter`), but lacks built-in SCSS or TypeScript support. For these, use Laravel Mix/Vite or install third-party plugins (e.g., `leafo/scssphp` for SCSS). Performance may lag compared to JS-based tools.
How does Assetic’s performance compare to Webpack or Vite?
Assetic is slower (~500ms+ for large files) because it’s PHP-based, while Webpack/Vite (JS-based) process assets in ~100ms. Use Assetic only for dynamic or small-scale assets. For high-traffic apps, pair it with Laravel Mix for static assets or migrate entirely to Vite.
Is Assetic actively maintained? Should I fork it if needed?
The original Assetic (Symfony’s package) is stable but lacks Laravel-specific updates. The `bonami-cz/assetic` fork is unmaintained (0 stars/dependents). If critical, fork it or use a maintained alternative like `leafo/assetic` (Symfony 4+ compatible). Always audit dependencies for security.
Can I use Assetic for runtime CSS/JS generation (e.g., dynamic themes)?
Yes, Assetic excels at runtime generation. For example, compile user-uploaded CSS/JS on demand using `AssetCollection` with dynamic paths. Cache compiled assets in Laravel’s filesystem or Redis to avoid reprocessing. Avoid this for static assets due to performance overhead.
What are the alternatives to Assetic for Laravel asset management?
For modern apps, use **Laravel Mix** (Webpack) or **Vite** (esbuild/Rollup) for static assets. For PHP-only environments, consider **Encore** (Symfony’s Webpack bridge) or **Gulp/PHP-Gulp** hybrids. Assetic is a fallback for legacy systems or dynamic use cases where Node.js isn’t available.
How do I cache compiled assets in production with Assetic?
Assetic doesn’t integrate with Laravel’s cache system, so manually cache compiled assets using `Storage::put()` or Redis. Set `targetPath` to `public/build/asset-name-{hash}.css` and clear old files during deployments. For versioning, append `?v={{ filemtime() }}` to URLs or use Laravel’s `asset()` helper.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views