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

Bdev Assetic Bundle Laravel Package

boltconcepts/bdev-assetic-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation Add the bundle to your Laravel project via Composer:

    composer require boltconcepts/bdev-assetic-bundle
    

    Register the bundle in config/app.php under the providers array:

    BoltConcepts\BDevAsseticBundle\BDevAsseticBundle::class,
    
  2. Basic Configuration Publish the default configuration:

    php artisan vendor:publish --provider="BoltConcepts\BDevAsseticBundle\BDevAsseticBundle" --tag="config"
    

    Update config/bdev_assetic.php to match your project’s asset pipeline needs.

  3. First Use Case: Asset Dumping Define an asset in app/Assetic/config.php (or via YAML/JSON):

    return [
        'bundles' => [
            'app' => [
                'assets' => [
                    'css/app.css' => [
                        'inputs' => ['public/css/style.css'],
                        'filters' => ['cssrewrite', 'yui_css'],
                    ],
                ],
            ],
        ],
    ];
    

    Dump assets to disk:

    php artisan assetic:dump
    

Implementation Patterns

Workflows

  1. Asset Grouping Organize assets by logical bundles (e.g., admin, frontend) in config/bdev_assetic.php:

    'bundles' => [
        'admin' => [
            'assets' => [
                'js/admin.js' => ['inputs' => ['resources/js/admin/*.js']],
            ],
        ],
    ],
    

    Use {{ asset('bundles/admin/js/admin.js') }} in Blade templates.

  2. Environment-Specific Assets Leverage Symfony’s environment variables (e.g., APP_ENV) to conditionally load assets:

    'bundles' => [
        'dev' => [
            'assets' => ['css/dev-overrides.css' => ['inputs' => ['public/css/dev.css']]],
        ],
    ],
    
  3. Integration with Laravel Mix Use the bundle alongside Laravel Mix for hybrid workflows:

    • Compile assets with Mix (npm run dev).
    • Use BDevAsseticBundle for runtime processing (e.g., minification in production).

Integration Tips

  • Custom Filters: Extend Assetic filters by creating a service provider:
    use Assetic\Filter\FilterCollection;
    use Assetic\Filter\YuiJsFilter;
    
    public function register()
    {
        $this->app->extend('assetic.filter_collection', function (FilterCollection $collection) {
            $collection->add('custom_js', new YuiJsFilter());
            return $collection;
        });
    }
    
  • Dynamic Asset Loading: Fetch asset definitions from a database or API and merge them into the config:
    $dynamicAssets = DB::table('assets')->get();
    $config = array_merge(config('bdev_assetic'), ['bundles' => ['dynamic' => ['assets' => $dynamicAssets]]]);
    

Gotchas and Tips

Pitfalls

  1. Caching Quirks

    • Clear Assetic cache after config changes:
      php artisan cache:clear
      php artisan assetic:clear-cache
      
    • Use ?v=<timestamp> in asset URLs to bypass cache during development.
  2. Dependency Conflicts

    • Ensure symfony/assetic-bundle is installed (this bundle extends it):
      composer require symfony/assetic-bundle
      
    • Avoid version mismatches between BDevAsseticBundle and AsseticBundle.
  3. Laravel-Specific Issues

    • Public Path: Ensure public_path() is correctly set in config/bdev_assetic.php:
      'public_path' => public_path(),
      
    • Blade Integration: Use asset() helper or {{ asset() }} in Blade, not {{ url() }} for processed assets.

Debugging

  • Verbose Output: Enable debug mode in config/bdev_assetic.php:
    'debug' => env('APP_DEBUG', false),
    
  • Log Filters: Check storage/logs/laravel.log for Assetic filter errors.

Extension Points

  1. Custom Asset Dump Command Extend the default assetic:dump command:

    php artisan make:command CustomAsseticDump
    

    Override handle() to add pre/post-processing logic.

  2. Asset Versioning Automate versioning with a custom filter:

    use Assetic\Asset\AssetCollection;
    
    $collection = new AssetCollection(['css/app.css']);
    $collection->setTargetPath('public/build/app-' . hash('crc32b', file_get_contents('public/css/app.css')) . '.css');
    
  3. Asset Manifest Generate a JSON manifest of processed assets for SPAs:

    $manifest = [];
    foreach (config('bdev_assetic.bundles') as $bundle => $config) {
        foreach ($config['assets'] as $output => $asset) {
            $manifest[$output] = asset($output);
        }
    }
    file_put_contents(public_path('assets.json'), json_encode($manifest));
    
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui