hostnet/asset-bundle
Hostnet AssetBundle is a Symfony bundle for organizing and serving front-end assets. It provides configurable asset collections, Twig helpers, and compilation workflows, making CSS and JavaScript management consistent across PHP applications.
hostnet/asset-bundle is a thin Symfony integration layer for hostnet/asset-lib. It does not replace Webpack Encore, AssetMapper, or Symfony's Asset component; it mainly wires the asset library into the Symfony container and exposes configuration. The package has very low adoption and minimal maintenance activity, so start by confirming compatibility rather than assuming it is a drop-in asset system.
As of release 1.0.7, the bundle requires Symfony 5.4 or newer (Minimum symfony version: 5.4). There is no stated upper bound, so verify Symfony 6.x/7.x support against the actual composer.json constraints before adopting it.
Minimal path:
composer.json constraints for the bundle and hostnet/asset-lib against the app's PHP/Symfony version. Treat Symfony 5.4 as the floor.composer require hostnet/asset-bundle
// config/bundles.php
return [
// ...
Hostnet\Bundle\AssetBundle\HostnetAssetBundle::class => ['all' => true],
];
vendor/hostnet/asset-bundle/README.mdvendor/hostnet/asset-bundle/src/DependencyInjection/Configuration.phpvendor/hostnet/asset-bundle/src/DependencyInjection/*Extension.phpvendor/hostnet/asset-libbin/console config:dump-reference hostnet_asset
bin/console debug:container | grep -i asset
If the guessed alias fails, use the extension alias from the bundle's DI extension class.First practical use case: configure one asset collection or asset definition through the bundle, inject the resulting hostnet/asset-lib service into a controller or small Twig extension, and render it in a base layout. Keep the first change narrow: one CSS/JS entry, one environment, one rendered page. Once that works, expand to environment-specific configuration and cache busting.
Treat the bundle as a configuration adapter, not as the place to put application asset logic. The day-to-day pattern is: define assets in Symfony config, consume hostnet/asset-lib services through dependency injection, and wrap the vendor API behind a small application service.
Common patterns:
config/packages/hostnet_asset.yaml. Use when@dev and when@prod for differences such as minification, cache directories, or versioning.App\Asset\AssetRenderer and implement it using hostnet/asset-lib. This isolates the low-maintenance dependency and makes future replacement with Symfony AssetMapper/Encore easier.dev, prefer unminified assets and disabled caches. In prod, enable versioning/caching and fail fast if an asset is missing.APP_VERSION, a git hash, or a build timestamp in the application wrapper.services:
App\Asset\AssetRenderer:
alias: hostnet_asset.some_service
Verify the actual service ID with debug:container before relying on it.bin/console lint:container and debug:container to catch wiring errors. Add one functional test that renders a layout containing the asset output. Unit-test the application wrapper with a mocked asset-lib service.Integration tip: inspect the container after enabling the bundle. The most reliable documentation for this package is its DI configuration and the hostnet/asset-lib service definitions.
composer.json. If Composer conflicts appear, do not force-resolve them in a production app without testing the bundle's DI extension.Configuration.php/the DI extension. Use config:dump-reference against that alias, not a guessed name.config/bundles.php; older apps use AppKernel. After changing registration or config, run bin/console cache:clear.%kernel.project_dir% explicitly.var/cache or a configured directory. Ensure the web user can write there and warm the cache during deploy.bin/console debug:config hostnet_asset
bin/console debug:container | grep -i hostnet
bin/console lint:container
bin/console cache:clear
Then inspect the resolved asset path and rendered HTML in dev.hostnet/asset-lib source/tests rather than blog posts. If the bundle only exposes a small amount of config, most behavior will be defined by asset-lib, not the bundle.How can I help you explore Laravel packages today?