Welcome Guest, Not a member yet? Register   Sign In
Routes no other than GET return main page
#1

Hello there, I have this peculiar problem - I tinker around making CRUD REST API and I have defined these routes
PHP Code:
$routes->group('api/v1', ['namespace' => 'Api\V1''filter' => 'ApiGuard'],
    static function ($routes) {
        $routes->get('companies/(:num).json''\App\Controllers\Api\V1\Companies::company/$1');
        $routes->get('companies.json''\App\Controllers\Api\V1\Companies::fetchAll');
        $routes->post('companies/(:num).json''Companies::post');
        $routes->put('companies/(:num).json''Companies::put');
        $routes->delete('companies/(:num).json''Companies::delete');
    }
); 
In any case apart from GET method I get 303 redirect to main page, whereas via Guzzle I get 404 Not Found error. What have I done wrong here?
Thank you for your help.
Reply
#2

If you use the "namespace" option, then you need to specify the full namespace.
['namespace' => '\App\Controllers\Api\V1'
Reply




Theme © iAndrew 2016 - Forum software by © MyBB