Q:

Laravel, Class controller does not exist in route with prefixes

Namespace in group (or callback) don't work (Lumen, Laravel)? I want to remove the code from routes.php to controllers. And so!
use App\Http\Controllers;

// OK!
$app->get('path', 'BarController@getId');

$app->group(['prefix' => 'foo'], function ($app) {
    // OK!
    $app->get('path', '\App\Http\Controllers\BarController@getId');

    // Class BarController does not exist
    $app->get('path', 'BarController@getId');
});

A:

For your use statement to work, you'll have to use the ::class syntax:
use App\Http\Controllers\BarController;

$app->get('path', BarController::class.'@getId');

Alternatively, you can add the namespace to your group:
$app->group(['prefix' => 'foo', 'namespace' => 'App\Http\Controllers'], function ($app) {
    $app->get('path', 'BarController@getId');
});

