0
votes

I have a Laravel structure like this:

app/
   Http/
       Controllers/
          Api/
          Auth/
              RegisterController

and the API route:

 // AUTH
   Route::namespace('Api')->group(function () {
     Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
     Route::post('password/reset', 'Auth\ResetPasswordController@reset');
     Route::post('register', 'Auth\RegisterController@register');
});

But the POST request to http://domain.xx/api/register return an internal error:

Class App\Http\Controllers\Api\Auth\RegisterController does not exist in file...

I've tried pointing to '..\Auth\RegisterController@register' but I got same error:

Class ..\Auth\RegisterController does not exist in file

It should be simple to fix lol... but... can you help me?

2
As per your folder structure api and auth is at same level but you are using it as parent childRahul
move your Auth directory inside Api Folder or you have to make changes in routing Route::post('register', 'Auth\RegisterController@register'); outside Route groupAmit Sahu

2 Answers

0
votes

Routes Group

Route::group(['prefix' => 'api', 'namespace' => 'App\Http\Controllers'], function()
{
    Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
     Route::post('password/reset', 'Auth\ResetPasswordController@reset');
     Route::post('register', 'Auth\RegisterController@register');
});

You can delete folder App\Http\Controllers\Api, you can use PREFIX on your group routes

0
votes

I fixed it

 // AUTH
   Route::namespace('Auth')->group(function () {
   Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail');
   Route::post('password/reset', 'ResetPasswordController@reset');
   Route::post('register', 'RegisterController@register');

});