I'm using the Laravel PHP framework and am wondering about a few things. The default application/routes.php file contains this:
Route::get('/', function()
{
    return View::make('home.index');
});
This just outputs the view, but how do I call a controller from there?
I can delete the entire route above and replace it with Route::controller('home') which seems to use the home controller on the default URL (i.e. example.com/). But any other controller like Route::controller('article') doesn't work, only on example.com/article. How would I set the article controller as the default?
Just pass the controller as a string, with @ between the class name and the method name:
Route::get('/', 'article@index');
Read the docs (scroll to the example by the title Registering a route that points to a controller action).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With