checkdomain/assets-extra-bundle
Installation:
composer require checkdomain/assets-extra-bundle:dev-master
Register the bundle in app/AppKernel.php:
new Checkdomain\AssetsExtraBundle\CheckdomainAssetsExtraBundle(),
First Use Case:
Enable logical file names in Twig templates by configuring the bundle to override the default bundles directory. Update config.yml:
checkdomain_assets_extra:
assets_dir: "%kernel.root_dir%/../web/assets" # Custom assets directory
encrypt_bundle_names: true # Optional: Encrypt bundle names in paths
Now reference assets logically in Twig:
<link rel="stylesheet" href="{{ asset('css/styles.css') }}">
Asset Directory Customization:
bundles/ directory by setting assets_dir in config. Useful for shared assets across projects.web/assets for easier deployment.Bundle Name Encryption:
encrypt_bundle_names to obfuscate bundle names in asset paths (security through obscurity).Assetic Integration:
CssRewriteFilter to fix path resolution for logical file names.config.yml:
assetic:
filters:
cssrewrite: ~ # Automatically fixed by the bundle
Twig asset() Function:
CssRewriteFilter is applied after asset() processing in Assetic configs to avoid path conflicts.dev environments for easier debugging:
checkdomain_assets_extra:
encrypt_bundle_names: "%kernel.debug% ? false : true"
Deprecated Symfony 2:
symfony/framework-bundle).Assetic Path Resolution Bug:
CssRewriteFilter fails, ensure:
assets_dir config points to the root of your assets (not a subdirectory).use_controller is set to false in config.yml:
assetic:
use_controller: false
Twig Caching:
assets_dir or encryption settings:
php bin/console cache:clear --env=prod
Logical File Names Limitation:
assets_dir. External assets (e.g., CDN) require manual paths.Verify Config: Check if the bundle is loaded by dumping kernel bundles:
// app/AppKernel.php
dump(array_keys($this->getBundles()));
Look for CheckdomainAssetsExtraBundle.
Asset Paths:
Debug Twig’s asset() output with:
{{ dump(asset('css/styles.css')) }}
Ensure paths resolve correctly.
Assetic Logs:
Enable Assetic debug mode in config.yml:
assetic:
debug: "%kernel.debug%"
Check logs for CssRewriteFilter errors.
Custom Filters:
Extend the bundle by creating a custom Assetic filter that inherits from Checkdomain\AssetsExtraBundle\Twig\Extension\AssetExtension.
Dynamic Asset Directories:
Override the getAssetsDir() method in a service to fetch assets_dir dynamically (e.g., from environment variables).
Encryption Logic:
Modify the encryption algorithm by extending the Checkdomain\AssetsExtraBundle\DependencyInjection\Configuration class.
How can I help you explore Laravel packages today?