diff --git a/laravel/cli/dependencies.php b/laravel/cli/dependencies.php index 5ce03fd0..2a665b8e 100644 --- a/laravel/cli/dependencies.php +++ b/laravel/cli/dependencies.php @@ -46,6 +46,16 @@ return new Tasks\Session\Manager; }); +/** + * The route task is responsible for calling routes within the + * application and dumping the result. This allows for simple + * testing of APIs and JSON based applications. + */ +IoC::singleton('task: route', function() +{ + return new Tasks\Route; +}); + /** * The "test" task is responsible for running the unit tests for * the application, bundles, and the core framework itself. diff --git a/laravel/cli/tasks/route.php b/laravel/cli/tasks/route.php new file mode 100644 index 00000000..6c2eccc7 --- /dev/null +++ b/laravel/cli/tasks/route.php @@ -0,0 +1,56 @@ +route(); + + echo PHP_EOL; + } + + /** + * Dump the results of the currently established route. + * + * @return void + */ + protected function route() + { + // We'll call the router using the method and URI specified by + // the developer on the CLI. If a route is found, we will not + // run the filters, but simply dump the result. + $route = Router::route(Request::method(), URI::current()); + + if ( ! is_null($route)) + { + var_dump($route->response()); + } + else + { + echo '404: Not Found'; + } + } + +} \ No newline at end of file