adrenalinkin/custom-assets-bundle
Symfony bundle to install assets from custom source folders into your project’s public/custom_assets directory, similar to assets:install. Configure one or more source paths via YAML and optionally run automatically via a Composer post-install/update script.
Installation
Run composer require adrenalinkin/custom-assets-bundle in your Laravel project root.
(Note: The package is Symfony-based, but Laravel can integrate it via composer require and manual kernel registration.)
Register the Bundle
Add the bundle to config/app.php under the providers array:
Linkin\Bundle\CustomAssetsBundle\LinkinCustomAssetsBundle::class,
(Laravel 5.5+ uses autoloading, so no AppKernel.php is needed.)
Publish Configuration
Run php artisan vendor:publish --provider="Linkin\Bundle\CustomAssetsBundle\LinkinCustomAssetsBundle" --tag="config" to publish the default YAML config to config/custom_assets.yaml.
Configure Sources
Edit config/custom_assets.yaml to define your custom asset sources:
paths:
- { from: 'resources/custom-assets', to: 'custom_assets' }
(Maps a local folder to public/custom_assets.)
Install Assets
Run php artisan custom:assets:install to copy assets to the public directory.
Scenario: You need to bundle third-party assets (e.g., vendor JS/CSS, custom fonts, or legacy files) into your Laravel project without manual copying.
Workflow:
resources/custom-assets (or your configured from path).php artisan custom:assets:install./custom_assets/... in your app.Development Workflow
php artisan custom:assets:install --watch (if supported) to auto-sync changes during development.--watch flag; consider symlinking for live updates: ln -s resources/custom-assets public/custom_assets.)CI/CD Integration
php artisan custom:assets:install to your deployment script (e.g., deploy.php or GitHub Actions).php artisan config:clear && php artisan custom:assets:install --no-interaction
Dynamic Asset Loading
mix() or asset() helpers to reference copied files:
<link href="{{ asset('custom_assets/css/vendor.css') }}" rel="stylesheet">
Symfony-Laravel Bridge:
app/Console/Kernel.php to add Laravel-specific logic:
protected function commands()
{
$this->load(__DIR__.'/../../vendor/adrenalinkin/custom-assets-bundle/src/Command');
$this->commands([
\App\Console\Commands\CustomAssetsCommand::class, // Custom wrapper
]);
}
Asset Versioning:
# config/custom_assets.yaml
version: '{{ env("ASSET_VERSION", "1.0") }}'
paths:
- { from: 'resources/custom-assets', to: 'custom_assets/v{{ version }}' }
Excluding Files:
.gitignore-style patterns in the config to skip files:
paths:
- { from: 'resources/custom-assets', to: 'custom_assets', exclude: ['*.log', 'temp/'] }
Laravel-Symfony Mismatch
Kernel and Container. If you encounter errors:
Filesystem or Finder in a service provider:
use Symfony\Component\Filesystem\Filesystem;
$this->app->singleton(Filesystem::class, function () {
return new Filesystem();
});
Permission Issues
public/custom_assets is writable:
chmod -R 755 public/custom_assets
storage:link may conflict; run php artisan storage:link first.)YAML Configuration Quirks
custom_assets.yaml.true/false (not yes/no).Overwriting Existing Files
\Linkin\Bundle\CustomAssetsBundle\Command\InstallCommand and implement incremental sync logic.Dry Run Mode:
--dry-run to the command to preview changes without copying:
php artisan custom:assets:install --dry-run
Verbose Output:
-v for detailed logs:
php artisan custom:assets:install -v
Custom Command Logic
namespace App\Console\Commands;
use Linkin\Bundle\CustomAssetsBundle\Command\InstallCommand as BaseInstallCommand;
class CustomAssetsInstallCommand extends BaseInstallCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
// Add logic before/after asset copy
parent::execute($input, $output);
}
}
Dynamic Path Resolution
$this->app->extend('custom_assets.path_resolver', function () {
return new \App\Services\CustomPathResolver();
});
Asset Processing
# config/custom_assets.yaml
processors:
- { type: 'css', command: 'php artisan vendor:publish --tag=laravel-mix' }
How can I help you explore Laravel packages today?