routes.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Application Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | Simply tell Laravel the HTTP verbs and URIs it should respond to. It is a
  8. | breeze to setup your applications using Laravel's RESTful routing, and it
  9. | is perfectly suited for building both large applications and simple APIs.
  10. | Enjoy the fresh air and simplicity of the framework.
  11. |
  12. | Let's respond to a simple GET request to http://example.com/hello:
  13. |
  14. | Router::register('GET /hello', function()
  15. | {
  16. | return 'Hello World!';
  17. | });
  18. |
  19. | You can even respond to more than one URI:
  20. |
  21. | Router::register('GET /hello, GET /world', function()
  22. | {
  23. | return 'Hello World!';
  24. | });
  25. |
  26. | It's easy to allow URI wildcards using (:num) or (:any):
  27. |
  28. | Router::register('GET /hello/(:any)', function($name)
  29. | {
  30. | return "Welcome, $name.";
  31. | });
  32. |
  33. */
  34. Route::get('/, home', array('as' => 'home', function()
  35. {
  36. return View::make('home.index');
  37. }));
  38. Route::controller(array(
  39. 'auth', 'filter', 'home', 'restful',
  40. 'template.basic', 'template.name', 'template.override',
  41. 'admin.panel',
  42. ));
  43. /*
  44. |--------------------------------------------------------------------------
  45. | Route Filters
  46. |--------------------------------------------------------------------------
  47. |
  48. | Filters provide a convenient method for attaching functionality to your
  49. | routes. The built-in "before" and "after" filters are called before and
  50. | after every request to your application, and you may even create other
  51. | filters that can be attached to individual routes.
  52. |
  53. | Let's walk through an example...
  54. |
  55. | First, define a filter:
  56. |
  57. | Filter::register('filter', function()
  58. | {
  59. | return 'Filtered!';
  60. | });
  61. |
  62. | Next, attach the filter to a route:
  63. |
  64. | Router::register('GET /', array('before' => 'filter', function()
  65. | {
  66. | return 'Hello World!';
  67. | }));
  68. |
  69. */
  70. Filter::register('before', function()
  71. {
  72. $_SERVER['before'] = true;
  73. });
  74. Filter::register('after', function()
  75. {
  76. $_SERVER['after'] = true;
  77. });
  78. Filter::register('csrf', function()
  79. {
  80. if (Request::forged()) return Response::error('500');
  81. });
  82. Filter::register('auth', function()
  83. {
  84. if (Auth::guest()) return Redirect::to('login');
  85. });