Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Routing][FrameworkBundle] Allow using env() in route conditions#35747

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

Merged

Conversation

atailouloute
Copy link
Contributor

@atailoulouteatailouloute commentedFeb 17, 2020
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PRTODO

This 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 (it supports also env processors/ loaders)

/** * @Route("/new-feature", condition="env('bool:IS_FEATURE_ENABLED') === true") */publicfunction__invoke(){echo"This will be executed only when APP_ENV = dev";}

TODOs:

  • Complete unit tests

Koc, zairigimad, Guikingone, juuuuuu, and antalaron reacted with thumbs up emoji
@atailouloute
Copy link
ContributorAuthor

/cc@nicolas-grekas@HeahDude Here is an experimentation/second implementation of#35727

@nicolas-grekasnicolas-grekas added this to thenext milestoneFeb 17, 2020
@atailoulouteatailoulouteforce-pushed theuse-env-in-route-condition branch 2 times, most recently frome1f164c to84a22c6CompareFebruary 17, 2020 14:32
@atailoulouteatailouloute changed the title[Routing][DependencyInjection][FrameworkBundle] Use env() in route condition[Routing][FrameworkBundle] Use env() in route conditionFeb 17, 2020
@atailoulouteatailoulouteforce-pushed theuse-env-in-route-condition branch 3 times, most recently fromb14fb2e to2d30cf3CompareFebruary 17, 2020 15:59
@atailoulouteatailoulouteforce-pushed theuse-env-in-route-condition branch 3 times, most recently from732ef18 toa40e319CompareFebruary 17, 2020 16:51
@atailoulouteatailoulouteforce-pushed theuse-env-in-route-condition branch 5 times, most recently from6177069 to9431dc6CompareFebruary 17, 2020 20:53
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Great, I like it a lot :)
Some minor details and good to go on my side.

atailouloute, HeahDude, and zairigimad reacted with hooray emoji
Copy link
Contributor

@HeahDudeHeahDude left a comment

Choose a reason for hiding this comment

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

atailouloute reacted with thumbs up emoji
Copy link
Contributor

@maxheliasmaxhelias left a comment

Choose a reason for hiding this comment

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

Nice!

@nicolas-grekasnicolas-grekas changed the title[Routing][FrameworkBundle] Use env() in route condition[Routing][FrameworkBundle] Allow using env() in route conditionFeb 18, 2020
@nicolas-grekasnicolas-grekas changed the title[Routing][FrameworkBundle] Allow using env() in route condition[Routing][FrameworkBundle] Allow using env() in route conditionsFeb 24, 2020
@nicolas-grekasnicolas-grekasforce-pushed theuse-env-in-route-condition branch 3 times, most recently fromff17ac7 to357fc77CompareFebruary 24, 2020 11:21
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

FYI, I improved the feature by adding a newrouting.expression_language_function tag to make adding new functions easy. This leveragesServiceProviderInterface and tagged locators.

atailouloute reacted with heart emoji
@fabpotfabpotforce-pushed theuse-env-in-route-condition branch from1beb7b0 tob574460CompareFebruary 25, 2020 13:01
@fabpot
Copy link
Member

Thank you@atailouloute.

@GromNaN
Copy link
Member

Thanks for this feature@atailouloute. I used it today to match host using env var; only way to make it dynamic with prebuild Symfony cache.
Doc PRsymfony/symfony-docs#16610

andrew-demb reacted with thumbs up emoji

javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestMar 25, 2022
…mNaN)This PR was merged into the 5.4 branch.Discussion----------[Routing] doc for env() function in route conditionFix#13247 forsymfony/symfony#35747Very useful to match host based on env var.```yamlblog_list:    path: /blog    # the controller value has the format 'controller_class::method_name'    controller: App\Controller\BlogController::list    condition: "context.getHost() == env('APP_MAIN_HOST')"```Commits-------c22dc20 Documentation for env() function in route condition
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

@HeahDudeHeahDudeHeahDude approved these changes

@maxheliasmaxheliasmaxhelias approved these changes

@TobionTobionAwaiting requested review from Tobion

Assignees
No one assigned
Projects
None yet
Milestone
5.1
Development

Successfully merging this pull request may close these issues.

9 participants
@atailouloute@fabpot@GromNaN@nicolas-grekas@Tobion@chalasr@HeahDude@maxhelias@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp