Support the ongoing development of Laravel.io →
posted 9 years ago
Configuration
Last updated 2 years ago.
0

Hello, As far as I can see - you have wrong namespace. In order to get a controller from your \Api\V1 folder use group setting of namespace in such way:

Route::group(['domain' => 'api.medifaktor.de', 'namespace' => 'Api], function() {
     Route::group(['prefix' => 'v1', 'namespace' => 'v1'], function() {
        Route::get('incidents', array('as' => 'incidents', 'uses' => 'ApiIncidentsController@index'));
        Route::get('incidents/{id}', array('as' => 'showIncidents', 'uses' => 'IncidentsController@show'));
    });
});

This should work because you will tell Laravel to go into Api folder with first group and then to go into v1 with second group. Unless you are having more controllers in different directories - this is your solution. Otherwise please be aware that you need to type \Api\V1\YourController as your controller name.

0

Thank you!! Works perfectly fine!

0

Just don't forget that if you try to use a controller which is not in the specified group folder - you will get an error. In that case please use namespace on the required route.

Glad that I helped!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

sesc360 sesc360 Joined 16 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.