Roteamento no Laravel

Opa!

Galera eu to fazendo o exemplo do livro do laravel e está dando um erro com a implementação do cap 12, de autenticação, o problema é o segunte

InvalidArgumentException in RouteRegistrar.php line 75: Attribute [controllers] does not exist.

in RouteRegistrar.php line 75
at RouteRegistrar->attribute('controllers', array('auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController')) in Router.php line 1085
at Router->__call('controllers', array(array('auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController'))) in Facade.php line 221
at Facade::__callStatic('controllers', array(array('auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController'))) in web.php line 25
at require('C:\\Users\\Viggo\\Documents\\GitHub\\estoque-laravel\\routes\\web.php') in Router.php line 314
at Router->loadRoutes('C:\\Users\\Viggo\\Documents\\GitHub\\estoque-laravel\\routes/web.php') in Router.php line 270
at Router->group(array('middleware' => 'web', 'namespace' => 'estoque\\Http\\Controllers'), 'C:\\Users\\Viggo\\Documents\\GitHub\\estoque-laravel\\routes/web.php') in RouteRegistrar.php line 104
at RouteRegistrar->group('C:\\Users\\Viggo\\Documents\\GitHub\\estoque-laravel\\routes/web.php') in RouteServiceProvider.php line 56
at RouteServiceProvider->mapWebRoutes() in RouteServiceProvider.php line 40
at RouteServiceProvider->map()
at call_user_func_array(array(object(RouteServiceProvider), 'map'), array()) in BoundMethod.php line 28
at BoundMethod::Illuminate\Container\{closure}() in helpers.php line 912
at value(object(Closure)) in BoundMethod.php line 86
at BoundMethod::callBoundMethod(object(Application), array(object(RouteServiceProvider), 'map'), object(Closure)) in BoundMethod.php line 30
at BoundMethod::call(object(Application), array(object(RouteServiceProvider), 'map'), array(), null) in Container.php line 524
at Container->call(array(object(RouteServiceProvider), 'map')) in RouteServiceProvider.php line 70
at RouteServiceProvider->loadRoutes() in RouteServiceProvider.php line 30
at RouteServiceProvider->boot() in RouteServiceProvider.php line 28
at RouteServiceProvider->boot()
at call_user_func_array(array(object(RouteServiceProvider), 'boot'), array()) in BoundMethod.php line 28
at BoundMethod::Illuminate\Container\{closure}() in helpers.php line 912
at value(object(Closure)) in BoundMethod.php line 86
at BoundMethod::callBoundMethod(object(Application), array(object(RouteServiceProvider), 'boot'), object(Closure)) in BoundMethod.php line 30
at BoundMethod::call(object(Application), array(object(RouteServiceProvider), 'boot'), array(), null) in Container.php line 524
at Container->call(array(object(RouteServiceProvider), 'boot')) in Application.php line 762
at Application->bootProvider(object(RouteServiceProvider)) in Application.php line 745
at Application->Illuminate\Foundation\{closure}(object(RouteServiceProvider), 17)
at array_walk(array(object(EventServiceProvider), object(LogServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FormRequestServiceProvider), object(FoundationServiceProvider), object(NotificationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ViewServiceProvider), object(AppServiceProvider), object(AuthServiceProvider), object(EventServiceProvider), object(RouteServiceProvider)), object(Closure)) in Application.php line 746
at Application->boot() in BootProviders.php line 17
at BootProviders->bootstrap(object(Application)) in Application.php line 208
at Application->bootstrapWith(array('Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\HandleExceptions', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders')) in Kernel.php line 160
at Kernel->bootstrap() in Kernel.php line 144
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
at require_once('C:\\Users\\Viggo\\Documents\\GitHub\\estoque-laravel\\public\\index.php') in server.php line 21

Isso ocorreu depois que eu coloquei a linha:

Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',

]);

Por favor, me ajudem.

retire esta rota
Route::controllers([
‘auth’ => ‘Auth\AuthController’,
‘password’ => ‘Auth\PasswordController’,

]);
e escreva esta linha na pasta do seu projeto…
php artisan make:auth

agora ele criou a autenticação correta.

1 curtida

Eu tinha visto isso, mas o livro estava na versão 5 do laravel e com o comando php artisan make:auth, era gerado essa rota que falei, em todo caso, eu atualizei a versão do laravel e usei o comando que você falou, deu tudo certo! Vlws.

<< solução >>

Não estava conseguindo na Laravel antiga, atualizei para nova versao 7, e o problema continuava, entao achei na documentação, basta executar todos comandos nesse link: https://laravel.com/docs/7.x/authentication#authentication-quickstart