[Routing] added hostname pattern #1894

Merged
merged 1 commit into from Nov 22, 2012

Conversation

Projects
None yet
7 participants
Contributor

arnaud-lb commented Nov 5, 2012

This adds documentation for symfony/symfony#3378

@alvarezmario alvarezmario commented on the diff Nov 5, 2012

book/routing.rst
@@ -692,6 +692,120 @@ form via the same URL, while using distinct controllers for the two actions.
Like the other requirements, the ``_method`` requirement is parsed as a regular
expression. To match ``GET`` *or* ``POST`` requests, you can use ``GET|POST``.
+Adding a Hostname Pattern
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
@alvarezmario

alvarezmario Nov 5, 2012

Contributor

@arnaud-lb You must specified that this feature is new in Symfony2.2

@arnaud-lb

arnaud-lb Nov 5, 2012

Contributor

done

@stof stof and 1 other commented on an outdated diff Nov 5, 2012

book/routing.rst
@@ -692,6 +692,123 @@ form via the same URL, while using distinct controllers for the two actions.
Like the other requirements, the ``_method`` requirement is parsed as a regular
expression. To match ``GET`` *or* ``POST`` requests, you can use ``GET|POST``.
+Adding a Hostname Pattern
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. versionadded:: 2.2
+ Hostname matching support was added in Symfony 2.2
+
+You can also match on the HTTP *hostname* of the incomming request:
+
+.. configuration-block::
+
+ .. code-block:: yaml
+
+ mobile_homepage:
+ pattern: /
+ hostname_pattern: m\.example\.com
@stof

stof Nov 5, 2012

Member

why adding backslashes before dots ? It is not a regex here

@arnaud-lb

arnaud-lb Nov 5, 2012

Contributor

oups

Contributor

vicb commented Nov 12, 2012

👍

@johnkary johnkary commented on an outdated diff Nov 12, 2012

book/routing.rst
@@ -692,6 +692,123 @@ form via the same URL, while using distinct controllers for the two actions.
Like the other requirements, the ``_method`` requirement is parsed as a regular
expression. To match ``GET`` *or* ``POST`` requests, you can use ``GET|POST``.
+Adding a Hostname Pattern
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. versionadded:: 2.2
+ Hostname matching support was added in Symfony 2.2
+
+You can also match on the HTTP *hostname* of the incomming request:
@johnkary

johnkary Nov 12, 2012

Contributor

Typo: incomming should be incoming

Contributor

alvarezmario commented Nov 12, 2012

Is there something I need to setup in the .htaccess for this to work? My browser is lost and cannot find the url.

@Tobion Tobion commented on the diff Nov 12, 2012

book/routing.rst
+Placeholders can be used in hostname patterns as well as in patterns, and
+requirements also apply to them.
+
+In the following example we avoid hardcoding the domain name by using a
+placeholder and a requirement:
+
+.. configuration-block::
+
+ .. code-block:: yaml
+
+ mobile_homepage:
+ pattern: /
+ hostname_pattern: m.{domain}
+ defaults: { _controller: AcmeDemoBundle:Main:mobileHomepage }
+ requirements:
+ domain: %domain%
@Tobion

Tobion Nov 12, 2012

Member

%domain% is not defined anywhere, nor explained that it would be replaced by a container param

@weaverryan weaverryan added a commit that referenced this pull request Nov 22, 2012

@weaverryan weaverryan Merge pull request #1894 from arnaud-lb/hostname
[Routing] added hostname pattern
856369b

@weaverryan weaverryan merged commit 856369b into symfony:master Nov 22, 2012

@weaverryan weaverryan added a commit that referenced this pull request Nov 22, 2012

@weaverryan weaverryan [#1894] Refactoring the hostname routing stuff into a component "cook…
…book" article with inter-links
1d2aefa
Member

weaverryan commented Nov 22, 2012

Hi Arnaud!

Very nice PR! I've merged it in, but also refactored the majority of the new documentation into a new entry inside the routing component (with links to this article). Please let me know if you see any errors or want to make any changes!

Thanks!

Contributor

arnaud-lb commented Nov 22, 2012

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment