laravel / fortify

Backend controllers and scaffolding for Laravel authentication.
https://laravel.com/docs/fortify
MIT License
1.62k stars 294 forks source link

Fortify assigns 2 named routes `register`, causing route:cache to fail #135

Closed jeffwhansen closed 4 years ago

jeffwhansen commented 4 years ago

Description:

Attempting to run route:cache results in the following exception:

LogicException

Unable to prepare route [register] for serialization. Another route has already been assigned name [register].

at vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php:212 208▕ $route->name($name = $this->generateRouteName()); 209▕ 210▕ $this->add($route); 211▕ } elseif (! is_null($symfonyRoutes->get($name))) { ➜ 212▕ throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}]."); 213▕ } 214▕ 215▕ $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute()); 216▕

More Info

route:list shows 2 entries for named route register Laravel\Fortify\Http\Controllers\RegisteredUserController@store and Laravel\Fortify\Http\Controllers\RegisteredUserController@create

Code in fortify/routes/routes.php

// Registration...
if (Features::enabled(Features::registration())) {
    Route::get('/register', 'RegisteredUserController@create')
                ->middleware(['guest'])
                **->name('register');**

    Route::post('/register', 'RegisteredUserController@store')
                ->middleware(['guest'])
                **->name('register');**
}
driesvints commented 4 years ago

There's no such line in the latest version. Please update to the latest version and try again.

https://github.com/laravel/fortify/blob/1.x/routes/routes.php#L72