1
votes

I got this

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

when I tried to go to http:/localhost/api/v1

But I declare my routes.php already. See here

Route::group(array('prefix' => 'api/v1', 'before' => 'auth.basic'), function(){
    Route::resource('url', 'UrlController');
});

and my filters.php look like this

Route::filter('api', function() {

    // Fetch a user record based on UN + PW     
    $user = User::where('username', '=', Input::get('username'))
    ->where('password', '=', Input::get('password'))
                ->take(1)
                ->get();

    if ($user->count() > 0) {
        Auth::onceUsingId($user[0]->id); // Authorize the user for this one request
    } else {
        return Response::view('errors.404', array(), 404)->header('Content-Type', 'application/json');
    }});

My index function in my Controller look like this

<?php

class UrlController extends \BaseController {

    public function index(){
        return Response::json(User::all());
    }
}

It should show a list json file. I am not sure why it does that ? Can someone help me point out what I did wrong ?

Thanks.

1

1 Answers

0
votes

The way you declared your route you would need to go to /api/v1/url to get to the index action.

You could either use that URL or change your routes like this:

Route::group(array('prefix' => 'api/v1', 'before' => 'auth.basic'), function(){
    Route::resource('/', 'UrlController');
});