Skip to content

Symfony 7: Asset mapper

  • load css and js;
  • makes anything in assets publicly available;
  • related: "LAST Stack";
  • uses asset versioning;
# Setup
composer require symfony/asset-mapper

# Asset function in twig ("render assets")
composer require symfony/asset

# Debug (list assets)
syc debug:asset-map

Troubleshooting

# clear cache
syc cache:clear

# "Check for security vulnerability advisories for dependencies"
syc importmap:audit

Importmap

# "Download all assets that should be downloaded"
syc importmap:install
# check outdated packages 
syc importmap:outdated
# update packages
syc importmap:update
# remove package
# only removes main package form importmap.php, does not remove related (eg. bootstrap css remains, @popperjs remains
syc importmap:remove PACKAGE
# workaround: remove assets/vendor/*, the run install command