sfDomainRoutePlugin - 0.1.2

Extend Symfony's routing to allow effective use of domains and subdomains

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
sfDomainRoutePlugin 0.1.2alpha for sf 1.2 MIT
Plugin image
21
users
Sign-in
to change
your status

sfDomainRoutePlugin lets you easily pass parameters in the subdomain (e.g. username.domain.com), limit routes to certain subdomains (e.g. www.domain.com to one route and blog.subdomain.com to another), and generate proper urls between different subdomains.

The sfDomainRoutePlugin extends Symfony's routing to allow effective use of subdomains and domains.

Features

  • Pass and retrieve parameters in the subdomain.
  • Limit routes to certain domains or subdomains.
  • Generate urls across subdomains.

Sample Usage (Detailed instructions are in the README)

echo link_to('Blog', '@blog');
/* Will generate a link to http://blog.greenanysite.com/ */
 
echo link_to('Homepage', '@homepage');
/* Will generate a link to http://www.greenanysite.com/ */
 
echo link_to('Tal Ater', '@userpage?subdomain=talater');
/* Will generate a link to http://talater.greenanysite.com/ */

In the last example, you can easily retrieve the username in your action with:

$this->username = $request->getParameter('subdomain');

Configuring all of this is very simple:

#Sample route limited to a number of subdomains
homepage:
  url:          /
  class:        sfDomainRoute
  param:        { module: homepage, action: index }
  requirements:
    sf_host:    [www.greenanysite.com, greenanysite.com]
 
#Sample route limited to one subdomain
blog:
  url:          /
  class:        sfDomainRoute
  param:        { module: blog, action: index }
  requirements:
    sf_host:    blog.greenanysite.com
 
#Sample route that will capture the subdomain name as a parameter
user_page:
  url:          /
  class:        sfDomainRoute
  param:        { module: user, action: index }

I am also working on adding support for different domain names (and not just subdomains).

This can be very handy for example for pointing multiple domains at the same application and having each one display different data (e.g. www.XboxNews.com, www.PS3News.com, www.WiiNews.com can all easily run from the same application but display different content.)

Developers

Name Status Email
gravatar Tal Ater lead moc.retalat <<ta>> lat

License

Show source

Copyright (c) 2009 Tal Ater

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.