routes.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. Router::register(array('GET /', 'GET /home'), function()
  35. {
  36. var_dump(Bundle::$bundles);
  37. return View::make('home.index');
  38. });
  39. /*
  40. |--------------------------------------------------------------------------
  41. | Route Filters
  42. |--------------------------------------------------------------------------
  43. |
  44. | Filters provide a convenient method for attaching functionality to your
  45. | routes. The built-in "before" and "after" filters are called before and
  46. | after every request to your application, and you may even create other
  47. | filters that can be attached to individual routes.
  48. |
  49. | Let's walk through an example...
  50. |
  51. | First, define a filter:
  52. |
  53. | Filter::register('filter', function()
  54. | {
  55. | return 'Filtered!';
  56. | });
  57. |
  58. | Next, attach the filter to a route:
  59. |
  60. | Router::register('GET /', array('before' => 'filter', function()
  61. | {
  62. | return 'Hello World!';
  63. | }));
  64. |
  65. */
  66. Filter::register('before', function()
  67. {
  68. // Do stuff before every request to your application...
  69. });
  70. Filter::register('after', function()
  71. {
  72. // Do stuff after every request to your application...
  73. });
  74. Filter::register('csrf', function()
  75. {
  76. if (Request::forged()) return Response::error('500');
  77. });
  78. Filter::register('auth', function()
  79. {
  80. if (Auth::guest()) return Redirect::to('login');
  81. });