I'm trying to use the Laravel framework in building my application. However, I'm getting stuck with routing.
Route
Route::get('ecatalogs',
array('as' => 'ecatalog_latest', 'uses' => 'ecatalogs@latest'));
Controller
class Catalogs_Controller extends Base_Controller
{
public $restful = true;
public function get_latest()
{
return "wohoooooo!";
}
}
My localhost files are stored in /Users/ariefbayu/Sites/
and my Laravel application is stored in /Users/ariefbayu/Sites/ecatalog/
. Inside this directory, I have an info.php
file to confirm if my path settings are working, and they do. However, when I navigate to http://localhost/ecatalog/public/index.php/ecatalogs
it always returns a 404 error. I know this is basic, but I don't know why this doesn't work.
FYI, I'm using a MAMP server, and I've set all source files' access permissions to 777
to test if this is a permission problem.
Route::get('ecatalogs', array('as'=>'ecatalog_latest', 'uses'=>'ecatalogs@latest'));
Notice the ecatalogs@latest
pointer. This tells Laravel to call the get_latest()
method on the Ecatalog_Controller
.
And this is your controller Catalogs_Controller
and function get_latest()
. You need to call the get_latest()
with this :
Route::get('ecatalogs', array('as'=>'ecatalog_latest', 'uses'=>'catalogs@latest'));