For some reason, which is probably my fault, Laravel thinks it should be looking for the class ApiController in path: 'App\Http\Controllers\App\Http\Controllers', so... it doubles, but I have no idea why.
It's a brand new Laravel 6 project, I've created the ApiController with the make:controller artisan command and added a function, like this:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ApiController extends Controller
{
public function base() {
return 'This is a test function';
}
}
Then I've added a route to the api routes like this:
use App\Http\Controllers\ApiController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::group(['prefix' => '/v1', 'as' => 'api'], function () {
Route::get('/base', ['uses' => ApiController::class . '@base'])->name('base');
});
As you can see, I've even 'imported' the controller, but it just can't find it. That's it, no other files or changes to the project. Also tried clearing route cache and dump-autoload, but that did not change anything.
app/Http/Controllers/ApiController.php
? Or is it perhapsAPIController.php
? – ceejayoz'uses' => ....
add the default namespace . You can do this instead[ApiController::class , 'base']
– Clément Baconnier