[Routing] [HttpKernel] [FrameworkBundle] Static Site Generation#10
Closed
[Routing] [HttpKernel] [FrameworkBundle] Static Site Generation#10
Conversation
432ae67 to
3ad1e9a
Compare
3749894 to
8e29cba
Compare
405b576 to
2e25ef3
Compare
2e25ef3 to
af81029
Compare
tBibaut
reviewed
Apr 29, 2025
src/Symfony/Bundle/FrameworkBundle/Command/StaticSiteGenerationGenerateCommand.php
Outdated
Show resolved
Hide resolved
tBibaut
reviewed
Apr 29, 2025
src/Symfony/Bundle/FrameworkBundle/Command/StaticSiteGenerationGenerateCommand.php
Show resolved
Hide resolved
tBibaut
reviewed
Jun 19, 2025
src/Symfony/Component/Routing/Tests/StaticSiteGeneration/StaticUriProviderTest.php
Outdated
Show resolved
Hide resolved
tBibaut
reviewed
Jun 19, 2025
tBibaut
reviewed
Jun 19, 2025
af81029 to
7816ddf
Compare
72f1933 to
d19d15a
Compare
d19d15a to
c75a434
Compare
ac75f50 to
a02e805
Compare
a02e805 to
a9e04cf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows a route to be defined as "static generated".
A static generated route is dumped on a storage thanks to a Symfony command:
static-site-generation:generate.With a simple NGINX / Caddy configuration, the generated files could be served directly.
Example with Caddy :
A good use case for this feature is a blog, where pages almost never change.
In that case, if the route is configured as static generated, Symfony won't even load, as the server serves the generate page directly (which implies a huge performance boost).
Similar implementations can be found in Tempest, Astro, and many other frameworks.
Here is an overview of the feature architecture:

StaticPageUrisProviderlists all Route marked as static, those can be defined as follows :staticGenerationconfiguration can be :routing.static_site.params_provider)There are some extension points :
StaticPageUrisProviderInterfaceto provide static page by another mean thansymfony/routing. A third party CMS system for example.ParamsProviderInterfaceto resolve params of dynamic routes. For example, with a route/blog/{slug}. We can create a param providers to list all slugs from a database, or all Markdown files in a directory.StaticPageDumperInterfaceto dump the pages content on another storage. Can be useful if we need to dump it to an S3 storage, to GitHub pages, ...