Skip to content

Add env variable for router.default_uri configuration option #1416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion symfony/routing/7.0/config/packages/routing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ framework:
router:
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
#default_uri: http://localhost
default_uri: '%env(DEFAULT_URI)%'

when@prod:
framework:
Expand Down
5 changes: 5 additions & 0 deletions symfony/routing/7.0/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
"aliases": ["router"],
"conflict": {
"symfony/framework-bundle": "<7.0"
},
"env": {
"#1": "Configure how to generate URLs in non-HTTP contexts, such as CLI commands.",
"#2": "See https://symfony.com/doc/current/routing.html#generating-urls-in-commands",
"DEFAULT_URI": "http://localhost"
Copy link
Member

@Kocal Kocal Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using the SYMFONY_PROJECT_DEFAULT_ROUTE_URL env var defined by the Symfony CLI, and fallback to http://localhost?

Suggested change
"DEFAULT_URI": "http://localhost"
"DEFAULT_URI": "${SYMFONY_PROJECT_DEFAULT_ROUTE_URL:-http://localhost}"

Refs:

Copy link
Member

@kbond kbond Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kocal, ah cool, I didn't know about this fallback syntax. I originally tried to use a Symfony env parser but these do not work in .env.

Copy link
Contributor Author

@alexander-schranz alexander-schranz Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find it a little bit strange as using real envs via ${} are never used in atleast the bundle recipes I know, but open what other reviewers mean.

Would more maybe go to change symfony cli to set DEFAULT_URI if this PR gets accepted.

}
}
Loading