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.
Notice the
ecatalogs@latestpointer. This tells Laravel to call theget_latest()method on theEcatalog_Controller.And this is your controller
Catalogs_Controllerand functionget_latest(). You need to call theget_latest()with this :