Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Routing] Use env() in route condition#35727
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
d71b869 tobb3ed99Compare
HeahDude left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for working on this
src/Symfony/Component/Routing/Matcher/ExpressionLanguageProvider.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Routing/Matcher/ExpressionLanguageProvider.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
HeahDude commentedFeb 14, 2020
Side note: the idea of using the expression language is to have a workaround the current |
bb3ed99 to9961615Compare9961615 to440aad7Compare440aad7 tob2a5967Comparestof commentedFeb 14, 2020
AFAICT, the service definition is useless for now, as it is not wired in the routing component at all. |
nicolas-grekas commentedFeb 14, 2020
I think this doesn't work: reading Instead, I'd suggest to find a way to pre-declare extra key=>value pairs that would be available to conditions (whom values could come from a real We just talked about this on Slack with@HeahDude, I invite you to get in touch with him for details (as he's the one pushing for this to happen :) ) |
atailouloute commentedFeb 14, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@stof, It is wired to Routing, there was already a compiler pass that does that |
…conditions (atailouloute)This PR was merged into the 5.1-dev branch.Discussion----------[Routing][FrameworkBundle] Allow using env() in route conditions| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets || License | MIT| Doc PR | TODOThis is a second implementation of#35727, it overcomes the limitation mentioned by nicolas in (#35727 (comment))The goal of this feature is to be able to use env variables in Route conditions```php/** *@route("/only-for-dev", condition="env('APP_ENV') === 'dev'") */public function __invoke(){ echo "This will be executed only when APP_ENV = dev";}```it supports also env processors/ loaders```php/** *@route("/only-for-dev", condition="env('trim:APP_ENV') === 'dev'") */````**TODOs:**- [x] Complete unit testsCommits-------b574460 [Routing][FrameworkBundle] Allow using env() in route conditions
Uh oh!
There was an error while loading.Please reload this page.
Added an
ExpressionLanguageProviderin the Routing component, that provides theenvfunction which could be used in route conditionsAn example of the feature
With a default value: