Skip to content

[FrameworkBundle] added new parameter router.request_context.url #35580

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

Closed
wants to merge 3 commits into from
Closed

[FrameworkBundle] added new parameter router.request_context.url #35580

wants to merge 3 commits into from

Conversation

pyatnitsev
Copy link

The router.request_context.url can be used instead of router.request_context / router.request_context.host etc to define url in console commands

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #35121
License MIT
Doc PR will be created after review

The router.request_context.url can be used instead of router.request_context / router.request_context.host etc to define url in console commands
@@ -489,6 +489,7 @@ private function addRouterSection(ArrayNodeDefinition $rootNode)
->scalarNode('host')->defaultValue('%router.request_context.host%')->end()
->scalarNode('scheme')->defaultValue('%router.request_context.scheme%')->end()
->scalarNode('base_url')->defaultValue('%router.request_context.base_url%')->end()
->scalarNode('url')->defaultValue('%router.request_context.url%')->end()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a config validation to check if this or others are filled but not both? To avoid « conflict »?

Also what about deprecating others if it does the same?

Copy link
Author

Choose a reason for hiding this comment

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

It's a good question.

In this PR url syntax will override "standard" one. Validation may be useful too.
I think, that deprication is not needed, becouse old syntax can be useful. For example, user can pass only base_url.

@ro0NL
Copy link
Contributor

ro0NL commented Feb 4, 2020

didnt we solve it with #35281 already?

Im not sure introducing more params is for the better, as we moved to semantic config.

Is the url node really preferred? Isnt it fine to configure the host/scheme/base_url nodes as-is :/

@nicolas-grekas nicolas-grekas added this to the next milestone Feb 4, 2020
@pyatnitsev
Copy link
Author

@ro0NL, url node is not prefered, but it useful for some developers I see. Configure of host / sheme / base url is fine, and url is just a new way todo it. Shortcut in a way.

Copy link
Member

@nicolas-grekas nicolas-grekas left a 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.
I would suggest two non-trivial changes here:

  • we should support only the new "base_uri" option in the config - let's drop the 3 others
  • the parameter should be read at runtime, to make it compatible with env vars. This means it cannot be processed in a compiler pass, but where the value is needed at runtime.
    Up to give it a try?

@pyatnitsev
Copy link
Author

@nicolas-grekas, thanks for you review.

Do you have any idea, how to make it compatible with env vars? I understand, way with comliler pass, but how I can do that with envs? Can you give me a more detailed way?

@pyatnitsev
Copy link
Author

and by the way ... if I drop 3 others options... I will be BC break isn't it?

@nicolas-grekas
Copy link
Member

The options are new to master so they can be dropped if I recall correctly.
For the runtime logic, you should look where the parameters are used currently, and make this part able to deal with the new "base_uri".
I can't help more right now sorry.

@pyatnitsev
Copy link
Author

pyatnitsev commented Feb 4, 2020

Ok, will try. Thanks a lot.

@nicolas-grekas
Copy link
Member

Friendly ping @pyatnitsev

@pyatnitsev
Copy link
Author

Thank you for ping. I'll try to do this on this weekend.

@nicolas-grekas
Copy link
Member

Thank for opening @pyatnitsev, I took over in #36651

fabpot added a commit that referenced this pull request May 4, 2020
…RI with a DSN (nicolas-grekas)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[FrameworkBundle] Allow configuring the default base URI with a DSN

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fixes #35121, replaces #35580, partially reverts #35281
| License       | MIT
| Doc PR        | -

Instead of defining 3-4 parameters, this PR enables using a single DSN to configure the default URL context (for commands mainly):
```
framework:
	router:
		base_uri: 'https://my.host:8443/base-path/'
```

When using parameters directly, one can now set the same absolute URI in the `router.request_context.base_url` parameter, this will provide the same benefit.

Commits
-------

250fa7e [FrameworkBundle] Allow configuring the default base URI with a DSN
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FrameworkBundle] URL for setting the request context
6 participants