03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Multisites 207<br />

1 Route::group([<br />

2 "domain" => "dev.www.tutorial-laravel-4-multisites"<br />

3 ], function()<br />

4 {<br />

5 Route::any("/about", function()<br />

6 {<br />

7 return "This is the client-facing website.";<br />

8 });<br />

9 });<br />

10<br />

11 Route::group([<br />

12 "domain" => "dev.admin.tutorial-laravel-4-multisites"<br />

13 ], function()<br />

14 {<br />

15 Route::any("/about", function()<br />

16 {<br />

17 return "This is the admin site.";<br />

18 });<br />

19 });<br />

.<br />

This was extracted from app/routes.php.<br />

Aside from the basic routes Laravel 4 supports, it’s also possible to group routes within route<br />

groups. These groups provide an easy way of applying common logic, filtering and targeting specific<br />

domains.<br />

Not only can we explicitly target our different virtual host domains, we can target all subdomains<br />

with sub-domain wildcard:<br />

1 Route::group([<br />

2 "domain" => "dev.{sub}.tutorial-laravel-4-multisites"<br />

3 ], function()<br />

4 {<br />

5 Route::any("/whoami", function($sub)<br />

6 {<br />

7 return "You are in the '" . $sub . "' sub-domain.";<br />

8 });<br />

9 });

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!