Skip to content

Knowledgebase

Serving Symfony assets from the correct public directory

development

Symfony projects may use AssetMapper, a JavaScript build tool or directly managed public assets. The correct deployment step depends on the asset system installed in the project.

What you need before you begin

Inspect the repository for its asset configuration and build scripts. Identify the final public directory and whether the site is served at the domain root or below a path prefix.

01 Serve Symfony assets from the correct public directory

  1. Run the asset build or compilation command documented by the application. Use its lock files and supported build runtime rather than installing arbitrary latest frontend packages on the server.

  2. Include the generated public files and any asset manifest in the same release as the code that references them. Keep dependency source directories outside the document root.

  3. Configure the web server to serve existing public assets directly and send application routes to the front controller. Check any URL prefix or CDN configuration.

  4. Use versioned asset names or the project-supported cache-busting mechanism. Keep old assets long enough for already-open pages when a deployment changes filenames.

  5. Publish the release and inspect the browser network panel for CSS, JavaScript, font and image responses.

Confirm the expected result

Confirm assets return their proper content and MIME types rather than an HTML error page. Open a fresh page and test an already-open page across a controlled deployment.

Troubleshoot unexpected results

If pages are unstyled, compare generated filenames with the active manifest and document root. A 200 response containing the application HTML is still a failed asset request.

A common question

Does uploading the assets source directory complete deployment?

Not when the project requires compilation or a manifest. Deploy the output expected by the selected asset system and keep its build process repeatable.

Sources and further reading

Was this answer helpful?

Need a little more help?

Our support team can help you find the next step.

Contact support