The code has been duplicated and not moved for BC reasons.
This code has been duplicated in the Twig bundle to be able to decouple
the web profiler and the exception templates.
This PR was merged into the 2.0 branch.
Commits
-------
e12bd12 [HttpFoundation] Make host & methods really case insensitive in the RequestMacther
Discussion
----------
[HttpFoundation] Make host & methods really case insensitive in the Requ...
...estMacther
and backport changes from 2.2
Details:
- does not take case into account when checking the host (the `Request` always returns a lowercase value) to protect against user typo,
- makes the constructor case proof by invoking setters rather than setting properties directly (you could then add un unreachable method i.e; `get`)
Please propagate to 2.1/2.2 if accpeted. Thanks.
This PR was merged into the master branch.
Commits
-------
17f51a1 Merge pull request #6 from Tobion/hostname-routes
e120a7a fix API of RouteCollection
26e5684 some type fixes
514e27a [Routing] fix PhpMatcherDumper that returned numeric-indexed params that are returned besides named placeholders by preg_match
7ed3013 switch to array_replace instead of array_merge
94ec653 removed irrelevant string case in XmlFileLoader
9ffe3de synchronize the fixtures in different formats and fix default for numeric requirement
6cd3457 fixed CS
8366b8a [Routing] fixed validity check for hostname params in UrlGenerator
a8ce621 [Routing] added support for hostname in the apache matcher dumper
562174a [Routing] fixed indentation of dumped collections
1489021 fixed CS
a270458 [Routing] added some more unit tests
153fcf2 [Routing] added some unit tests for the PHP loader
68da6ad [Routing] added support for hostname in the XML loader
3dfca47 [Routing] added some unit tests for the YAML loader
92f9c15 [Routing] changed CompiledRoute signature to be more consistent
d91e5a2 [Routing] fixed Route annotation for hostname (should be hostname_pattern instead of hostnamePattern)
62de881 [Routing] clarified a variable content
11b4378 [Routing] added hostname support in UrlMatcher
fc015d5 [Routing] fixed route generation with a hostname pattern when the hostname is the same as the current one (no need to force the generated URL to be absolute)
462999d [Routing] display hostname pattern in router:debug output
805806a [Routing] added hostname matching support to UrlGenerator
7a15e00 [Routing] added hostname matching support to AnnotationClassLoader
cab450c [Routing] added hostname matching support to YamlFileLoader
85d11af [Routing] added hostname matching support to PhpMatcherDumper
402359b [Routing] added hostname matching support to RouteCompiler
add3658 [Routing] added hostname matching support to Route and RouteCollection
23feb37 [Routing] added hostname matching support to CompiledRoute
Discussion
----------
[2.2][Routing] hostname pattern for routes
Bug fix: no
Feature addition: yes
Fixes the following tickets: #1762, #3276
Backwards compatibility break: no
Symfony2 tests pass: yes
This adds a hostname_pattern property to routes. It works like the pattern property (hostname_pattern can have variables, requirements, etc). The hostname_pattern property can be set on both routes and route collections.
Yaml example:
``` yaml
# Setting the hostname_pattern for a whole collection of routes
AcmeBundle:
resource: "@AcmeBundle/Controller/"
type: annotation
prefix: /
hostname_pattern: {locale}.example.com
requirements:
locale: en|fr
# Setting the hostname_pattern for single route
some_route:
pattern: /hello/{name}
hostname_pattern: {locale}.example.com
requirements:
locale: en|fr
name: \w+
defaults:
_controller: Foo:bar:baz
```
Annotations example:
``` php
<?php
/**
* Inherits requirements and hostname pattern from the collection
* @Route("/foo")
*/
public function fooAction();
/**
* Set a specific hostnamePattern for this route only
* @Route("/foo", hostnamePattern="{_locale}.example.com", requirements={"_locale="fr|en"})
*/
public function fooAction();
```
Performance:
Consecutive routes with the same hostname pattern are grouped, and a single test is made against the hostname for this group, so the overhead is very low:
```
@Route("/foo", hostnamePattern="a.example.com")
@Route("/bar", hostnamePattern="a.example.com")
@Route("/baz", hostnamePattern="b.example.com")
```
is compiled like this:
```
if (hostname matches a.example.com) {
// test route "/foo"
// test route "/bar"
}
if (hostname matches b.example.com) {
// test route "/baz"
}
```
The PR also tries harder to optimize routes sharing the same prefix:
```
@Route("/cafe")
@Route("/cacao")
@Route("/coca")
```
is compiled like this:
```
if (url starts with /c) {
if (url starts with /ca) {
// test route "/cafe"
// test route "/cacao"
}
// test route "/coca"
}
```
---------------------------------------------------------------------------
by Koc at 2012-02-16T14:14:19Z
Interesting. Have you looked at #3057, #3002?
Killer feature of #3057 : multiple hostnames per route.
---------------------------------------------------------------------------
by arnaud-lb at 2012-02-16T14:21:28Z
@Koc yes, the main difference is that this PR allows variables in the hostname pattern, with requirements, etc just like the path pattern. The other PRs use a `_host` requirement, which works like the `_method` requirement (takes a list of allowed hostnames separated by `|`).
> Killer feature of #3057 : multiple hostnames per route.
If you have multiple tlds you can easily do it like this:
``` yaml
hostbased_route:
pattern: /
hostname_pattern: symfony.{tld}
requirements:
tld: org|com
```
Or with completely different domain names:
``` yaml
hostbased_route:
pattern: /
hostname_pattern: {domain}
requirements:
domain: example\.com|symfony\.com
```
Requirements allow DIC %parameters%, so you can also put you domains in your config.yml.
---------------------------------------------------------------------------
by Koc at 2012-02-16T15:52:16Z
wow, nice! So looks like this PR closes my #3276 ticket?
---------------------------------------------------------------------------
by arnaud-lb at 2012-02-16T15:53:55Z
Yes, apparently :)
---------------------------------------------------------------------------
by Koc at 2012-02-16T15:56:53Z
I cann't find method `ParameterBag::resolveValue` calling in this PR, like here https://github.com/symfony/symfony/pull/3316/files
---------------------------------------------------------------------------
by arnaud-lb at 2012-02-16T16:03:48Z
I think it's in core already
---------------------------------------------------------------------------
by Koc at 2012-02-16T16:11:38Z
looks like yes
https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php#L81
---------------------------------------------------------------------------
by dlsniper at 2012-02-16T19:37:57Z
This PR looks great, it's something like this I've been waiting for.
I know @fabpot said he's working on something similar but I think if he agrees with this it could be a great addition to the core.
@fabpot , @stof any objections about this PR if gets fully done?
---------------------------------------------------------------------------
by stof at 2012-02-16T20:00:21Z
Well, we already have 2 other implementations for this stuff in the PRs. @fabpot please take time to look at them
---------------------------------------------------------------------------
by stof at 2012-02-16T20:03:17Z
This one is absolutely not tested and seems to break the existing tests according to the description. So it cannot be reviewed as is.
---------------------------------------------------------------------------
by dlsniper at 2012-02-16T22:00:24Z
@stof I understand it's a WIP but the other PRs where ignored as well and like you've said, there's a bunch of PRs already on this issue all doing a thing or another. So an early feedback on this, or any other, could lead it to the right path in order to finally solve this issue.
---------------------------------------------------------------------------
by arnaud-lb at 2012-02-17T23:57:28Z
Added tests; others are passing now
---------------------------------------------------------------------------
by arnaud-lb at 2012-02-22T21:10:20Z
I'm going to add support for the Apache dumper and the XML loader; does this PR have a chance to be merged ? cc @fabpot @stof
---------------------------------------------------------------------------
by stof at 2012-02-22T22:05:23Z
@arnaud-lb We need to wait @fabpot's mind about the way he prefers to implement it to know which one can be merged.
---------------------------------------------------------------------------
by IjinPL at 2012-02-27T02:01:57Z
Forked @arnaud-lb *hostname_pattern* to add XML parasing support.
---------------------------------------------------------------------------
by stof at 2012-04-03T23:59:12Z
@arnaud-lb Please rebase your branch. It conflicts with master because of the move of the tests
@fabpot @vicb ping
---------------------------------------------------------------------------
by dlsniper at 2012-04-13T19:52:23Z
Hi,
If @arnaud-lb won't be able to rebase this I could help with some work on this but there's still the problem of actually choosing the right PR(s) for this issue. @blogsh says in his last commit that this PR is a bit better in his opinion but @fabpot needs to decide in the end.
---------------------------------------------------------------------------
by arnaud-lb at 2012-04-14T17:26:55Z
@stof rebased
---------------------------------------------------------------------------
by nomack84 at 2012-04-20T13:01:00Z
@fabpot Any final word about this pull request? It would be nice to have this feature ready for 2.1.
---------------------------------------------------------------------------
by asm89 at 2012-04-24T21:27:50Z
Using the `{_locale}` placeholder in the host would set the locale for the request just like it does now?
Another thing I'm wondering is how/if it should be possible to set the hostname pattern for all your routes, or at least when importing routes? Otherwise you'll end up repeating the same host pattern over and over again. I think this is also important when importing routes from third party bundles.
---------------------------------------------------------------------------
by fabpot at 2012-04-25T01:17:51Z
I'm reviewing this PR and I'm going to make some modifications. I will send a PR to @arnaud-lb soon.
---------------------------------------------------------------------------
by fabpot at 2012-04-25T03:10:18Z
I've sent a PR to @arnaud-lb arnaud-lb/symfony#3 that fixes some minor bugs and add support in more classes.
---------------------------------------------------------------------------
by fabpot at 2012-04-25T03:12:52Z
@asm89:
Placeholders in the hostname are managed in the same way as the ones from the URL pattern.
You can set a hostname pattern for a collection (like the prefix for URL patterns).
---------------------------------------------------------------------------
by Tobion at 2012-04-25T09:31:19Z
I think we need to change the contents of $variables, $tokens, and $hostnameTokens in the CompiledRoute. They contain redundant information and the content structure of these variables ist not documentation in any way. If we remove duplicated content and put it in a (single) well defined variable, it would also reduce the information that need to be saved in the generated class by the UrlGeneratorDumper.
---------------------------------------------------------------------------
by arnaud-lb at 2012-04-26T08:54:21Z
@fabpot thanks :) I've merged it
---------------------------------------------------------------------------
by stof at 2012-04-26T12:08:40Z
A rebase is needed
---------------------------------------------------------------------------
by fabpot at 2012-04-26T13:28:08Z
no need to rebase, I will resolve the conflicts when merging. I've still have some minor changes to do before merging though. Anyone willing to have a look at implementing the Apache dumper part?
---------------------------------------------------------------------------
by Tobion at 2012-04-26T14:59:00Z
@fabpot you want to merge this for 2.1 although it introduces big changes that need extensive review and testing? But #3958 is not considered for 2.1? I thought we are in some sort of feature freeze for the components in order to not postpone the release.
---------------------------------------------------------------------------
by fabpot at 2012-04-26T17:21:09Z
@Tobion: I never said it will be in 2.1. The plan is to create a 2.1 branch soon so that we can continue working on 2.2.
---------------------------------------------------------------------------
by Koc at 2012-04-26T19:46:43Z
https://twitter.com/#!/fabpot/status/178502663690915840
we don't need the logic to merge numeric keys, as we don't have them. I could also improve the genrated code by PhpMatcherDumper a little by saving a function call.
This PR was squashed before being merged into the master branch (closes#5928).
Commits
-------
6a033f3 setData method also accepts objects. Doc should reflect this.
Discussion
----------
setData method also accepts objects. Doc should reflect this.
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: NA
Todo: None
License of the code: MIT
Documentation PR: None
This PR was merged into the 2.1 branch.
Commits
-------
c659e78 Make YamlFileLoader and XmlFileLoader file loading extensible
Discussion
----------
Make YamlFileLoader and XmlFileLoader file loading extensible
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
Documentation PR: not needed
For phpBB we want to use a non-dumped container in the dev env to prevent having to clear the cache all the time. We're creating the container twice because we need some information at compile time which must be fetched from the container. The process is as follows:
Create temp container, get list of installed extensions (think bundles), create a compiler pass with the extensions list, create a new container with that compiler pass, compile it, dump it.
The problem is that we need to load and parse the YAML twice which is really slow. Caching it in the YamlFileLoader should save 50-100ms per page load.
By changing visibility to protected it becomes possible to extend the loader and cache file contents.
This PR was squashed before being merged into the master branch (closes#5904).
Commits
-------
84adcb1 [2.2][Routing] Added support for default attributes with default values of method params
Discussion
----------
[2.2][Routing] Added support for default attributes with default values of method params
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
With this patch, you can configure your default values likes this:
``` php
/**
* @Route("/hi/{name}", name="hi")
*/
public function hiAction($name = "Bob")
{
return new Response($name);
}
```
---------------------------------------------------------------------------
by Tobion at 2012-11-03T23:15:32Z
I'm unsure. How does one know if that param defines a default value or a requirement? It's too vague.
---------------------------------------------------------------------------
by lyrixx at 2012-11-03T23:35:27Z
It's only a default value, not a requirement.
It's just a shortcut to avoid `defaults={"name"="bob"}`
---------------------------------------------------------------------------
by Tobion at 2012-11-03T23:43:51Z
Yes, but its not clear. It could also be a shortcut to `requirements={"name"="bob"}`, which has totally different meaning. So it's not self-explanatory.
-1 for me.
---------------------------------------------------------------------------
by lyrixx at 2012-11-03T23:48:21Z
it is the default php behavior. It's a default value for a variable...
---------------------------------------------------------------------------
by stof at 2012-11-04T00:22:58Z
@Tobion using the default value of the method to set a requirement does not make any sense. I don't see why someone would expect this behavior
---------------------------------------------------------------------------
by fabpot at 2012-11-06T10:12:05Z
@lyrixx Can you add some unit tests?
---------------------------------------------------------------------------
by Tobion at 2012-11-06T10:28:42Z
Oh I misunderstood the PR. I thought this makes the `name` param default to `hi`. `@Route("/hi/{name}", name="hi")`. But it's just the name of the route. Your example was easy to misinterpret as you used `name` everywhere.
---------------------------------------------------------------------------
by fabpot at 2012-11-10T08:33:13Z
@lyrixx Can you finish this PR?
---------------------------------------------------------------------------
by lyrixx at 2012-11-10T13:16:34Z
@fabpot Yes i will as soon as possible.
---------------------------------------------------------------------------
by lyrixx at 2012-11-10T18:34:07Z
I rebase and amend my commit. (I changed doc in commit message to be less confusing)
I will try to add tests.
But for now, `AnnotationClassLoader::load` is not really tested, and `AnnotationClassLoader::addRoute` is absolutely not tested. So I think I should add tests for these methods ? And then add tests for my patch.
I will try tomorrow.
---------------------------------------------------------------------------
by lyrixx at 2012-11-11T18:23:41Z
@fabpot I added new tests. I tried to made very atomic commits.
This PR was merged into the master branch.
Commits
-------
bdf0334 Fixed the lap method. Added upgrade notes. Some CS fixes
Discussion
----------
Fixed the lap method. Added upgrade notes. Some CS fixes
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: ~
Todo: ~
License of the code: MIT
Documentation PR: ~
This adds some type-hinting to the Stopwatch components.
I've also split the Section class to its own file, I know it's not a must as per coding standards used by Symfony but it complies with most of the other classes in the framework.
I've updated the UPGRADE-2.2.md file as well.
There's a bug fix which I'm not sure it if should have been done in this branch or not.
Let me know if I should make this PR against an older version of the framework.
Thanks.
This PR was merged into the master branch.
Commits
-------
c7a8f7a [Routing] fixed possible parameters conflict in apache url matcher
Discussion
----------
[Routing] fixed possible parameters conflict in apache url matcher
Bug fix: yes
Feature addition: no
Backwards compatibility break: no (as long as rewrite rules are generated after upgrading)
Symfony2 tests pass: yes
- This fixes a conflict in route parameters:
The rewrite rules currently pass route informations through environment variables:
`_ROUTING_DEFAULT_x`: passes the default value of parameter x
`_ROUTING__allow_x`: passes the information that method x was allowed for this route
`_ROUTING_x`: passes the value of parameter x
The problem is that naming a route parameter `DEFAULT_*` or `_allow_*` would not behave as expected.
I fixed this by namespacing all environment variables; e.g. parameters are in `_ROUTING_param_*`, defaults in `_ROUTING_default_*`, etc.
- The PR fixes a second issue: sometimes the variables are prefixed with multiple REDIRECT_. This PR handles this case by ignoring them all.
- This also improves performance a little:
Matching a route with two parameters and two default parameters 100K times: (`$_SERVER` was copied from a real request, so with many non `_ROUTING_` variables)
master: 6.6s
this branch: 4.7s
---------------------------------------------------------------------------
by fabpot at 2012-10-27T13:37:24Z
Any news on this PR? Is it mergeable?
---------------------------------------------------------------------------
by arnaud-lb at 2012-10-27T14:50:08Z
There is an issue with default parameter values, I can't find how to fix that in a simple way. Before this PR, default values are never used (if a parameter is an optional not present in the url, the parameter's value is the empty string); after this PR, when a parameter is present and empty (e.g. a requirement like `.*`), its value is set to its default value.
---------------------------------------------------------------------------
by Tobion at 2012-10-29T01:36:08Z
The problem is, it's not consistent with the default php matcher. So one cannot safely exchange it with the apache matcher because it behaves differently under some (special) circumstances.
---------------------------------------------------------------------------
by fabpot at 2012-11-05T08:05:54Z
We need to move forward as I want to merge the hostname support in the routing ASAP to have plenty of time for feedback before the 2.2 release.
Does it sound reasonable to merge this PR as is an open a ticket about the remaining issue (which should not occur that often anyways)?
---------------------------------------------------------------------------
by arnaud-lb at 2012-11-05T09:22:02Z
@fabpot it sounds reasonable to me. Also, I've the hostname support branch is currently rebased so that it can be merged without this one.
---------------------------------------------------------------------------
by Tobion at 2012-11-11T21:50:20Z
Btw, does the ApacheMatcherDumper handle the _scheme requirement? It doesn't look like it. This would be another bug.
Anyway, we can probably merge this PR and open new issues for the remaining bugs.
This PR was merged into the master branch.
Commits
-------
d0e5ef1 [FrameworkBundle] move change note to changelog of FrameworkBundle instead of master UPGRADE-2.2
e77ecc9 [FrameworkBundle] switch to parameter for base url to make it configurable for tests and cli as done for host and scheme in d30943c2e8
Discussion
----------
[FrameworkBundle] switch to parameter for base url
This will make it configurable the same way we have it for host and scheme done for 2.1 in d30943c2e8
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: (no new test breakage)
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: (none yet. if this is merged, i will happily PR against doc if somebody can point me to the right place)
---------------------------------------------------------------------------
by dbu at 2012-11-11T18:44:33Z
doc will go here once its merged: http://symfony.com/doc/current/cookbook/console/generating_urls.html
---------------------------------------------------------------------------
by dbu at 2012-11-11T20:12:41Z
ok, moved to the FrameworkBundle changelog
---------------------------------------------------------------------------
by Tobion at 2012-11-11T20:34:28Z
unfortunately is naming is so wrong in many places of the Request class and the routing.
`base_url` is just an example. It's not an "URL" at all. It's a path only.
---------------------------------------------------------------------------
by dbu at 2012-11-12T07:47:55Z
@Tobion i saw that, but i chose to be consistent with the method name of RequestContext even if it is a wrong name.
This PR was merged into the master branch.
Commits
-------
e32ca2b [HttpKernel] Fix Symfony2 full framework tests
Discussion
----------
[HttpKernel] Fix Symfony2 full framework tests
Fix the path when the full framework is used
---------------------------------------------------------------------------
by fabpot at 2012-11-12T09:08:06Z
When is it broken?
---------------------------------------------------------------------------
by vicb at 2012-11-12T09:18:01Z
now, https://travis-ci.org/symfony/symfony/jobs/3159326
This PR was merged into the master branch.
Commits
-------
2972f31 [HttpKernel] Changlog update - document a BC break
Discussion
----------
[HttpKernel] Changlog update - document a BC break