Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0][BUG] Unable to prepare route for serialization. #2523

Closed
shbov opened this issue Mar 8, 2020 · 17 comments · Fixed by #2529
Closed

[4.0][BUG] Unable to prepare route for serialization. #2523

shbov opened this issue Mar 8, 2020 · 17 comments · Fixed by #2529
Labels

Comments

@shbov
Copy link

shbov commented Mar 8, 2020

Bug report

What I did

php artisan optimize

What happened

 LogicException

  Unable to prepare route [admin/category] for serialization. Another route has already been assigned name [admin.category.store].

  at C:\laragon\www\WTrans\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:206
    202|             $route->name($name = $this->generateRouteName());
    203|
    204|             $this->add($route);
    205|         } elseif (! is_null($symfonyRoutes->get($name))) {
  > 206|             throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}].");
    207|         }
    208|
    209|         $symfonyRoutes->add($name, $route->toSymfonyRoute());
    210|

  1   C:\laragon\www\WTrans\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:179
      Illuminate\Routing\AbstractRouteCollection::addToSymfonyRoutesCollection(Object(Symfony\Component\Routing\RouteCollection), Object(Illuminate\Routing\Route))

  2   C:\laragon\www\WTrans\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:246
      Illuminate\Routing\AbstractRouteCollection::toSymfonyRouteCollection()

Backpack, Laravel, PHP, DB version

### PHP VERSION:
PHP 7.4.2 (cli) (built: Jan 21 2020 17:52:43) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

### LARAVEL VERSION:
v7.0.8@d71ba61d51aec79a0a0f907991ec215dc24b09d4

### BACKPACK VERSION:
4.0.49@986f5e69593eab33e567787e0c28efb6747cd7b5
@welcome
Copy link

welcome bot commented Mar 8, 2020

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

@tabacitu
Copy link
Member

tabacitu commented Mar 9, 2020

Sorry @shbov , I don't think it's a bug in Backpack - I've just tried it and it seems to work fine in my projects:
Screenshot 2020-03-09 at 08 49 46

Take a closer look at all your routes, maybe you've created two Route::crud()s for category. Or maybe you have installed NewsCrud AND created your own CRUD for that. In that case, either remove the route of the CategoryCRUD in the package by overwriting its route file, or give your custom CategoryCRUD a different route name.

Hope it helps.
Cheers!

@tabacitu tabacitu closed this as completed Mar 9, 2020
@shbov
Copy link
Author

shbov commented Mar 9, 2020

Hi again. The error does not happen only for route admin/category, it's also happen to route admin/permission (or any route genereted by Route::crud). Maybe I'm doing something wrong.

routes/backpack/custom.php

Route::group([
    'prefix' => config('backpack.base.route_prefix', 'admin'),
    'middleware' => ['web', backpack_middleware()],
    'namespace' => 'App\Http\Controllers\Admin',
    'as' => config('backpack.base.route_prefix', 'admin') . '.',
], function () { // custom admin routes
    Route::crud('category', 'CategoryCrudController');
}); // this should be the absolute last line of this file

routes/backpack/permissionmanager.php

Route::group([
    'namespace'  => 'Backpack\PermissionManager\app\Http\Controllers',
    'prefix'     => config('backpack.base.route_prefix', 'admin'),
    'middleware' => ['web', backpack_middleware()],
], function () {
     Route::crud('permission', 'PermissionCrudController');
     Route::crud('role', 'RoleCrudController');
     Route::crud('user', 'UserCrudController');
});

php artisan route:list

+--------+----------------------------------------+----------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
| Domain | Method                                 | URI                                                | Name                           | Action                                                                                  | Middleware
                                                           |
+--------+----------------------------------------+----------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
|        | GET|HEAD                               | /                                                  | index                          | App\Http\Controllers\HomeController@index                                               | web,auth
                                                           |
|        | GET|HEAD                               | _debugbar/assets/javascript                        | debugbar.assets.js             | Barryvdh\Debugbar\Controllers\AssetController@js                                        | Barryvdh\Debugbar\Middleware\DebugbarEnabled,Closure                 |
|        | GET|HEAD                               | _debugbar/assets/stylesheets                       | debugbar.assets.css            | Barryvdh\Debugbar\Controllers\AssetController@css                                       | Barryvdh\Debugbar\Middleware\DebugbarEnabled,Closure                 |
|        | DELETE                                 | _debugbar/cache/{key}/{tags?}                      | debugbar.cache.delete          | Barryvdh\Debugbar\Controllers\CacheController@delete                                    | Barryvdh\Debugbar\Middleware\DebugbarEnabled,Closure                 |
|        | GET|HEAD                               | _debugbar/clockwork/{id}                           | debugbar.clockwork             | Barryvdh\Debugbar\Controllers\OpenHandlerController@clockwork                           | Barryvdh\Debugbar\Middleware\DebugbarEnabled,Closure                 |
|        | GET|HEAD                               | _debugbar/open                                     | debugbar.openhandler           | Barryvdh\Debugbar\Controllers\OpenHandlerController@handle                              | Barryvdh\Debugbar\Middleware\DebugbarEnabled,Closure                 |
|        | GET|HEAD                               | _debugbar/telescope/{id}                           | debugbar.telescope             | Barryvdh\Debugbar\Controllers\TelescopeController@show                                  | Barryvdh\Debugbar\Middleware\DebugbarEnabled,Closure                 |
|        | GET|HEAD                               | admin                                              | backpack                       | Backpack\CRUD\app\Http\Controllers\AdminController@redirect                             | web,admin
                                                           |
|        | GET|HEAD                               | admin/backup                                       |                                | Backpack\BackupManager\app\Http\Controllers\BackupController@index                      | web,admin
                                                           |
|        | PUT                                    | admin/backup/create                                |                                | Backpack\BackupManager\app\Http\Controllers\BackupController@create                     | web,admin
                                                           |
|        | DELETE                                 | admin/backup/delete/{file_name?}                   |                                | Backpack\BackupManager\app\Http\Controllers\BackupController@delete                     | web,admin
                                                           |
|        | GET|HEAD                               | admin/backup/download/{file_name?}                 |                                | Backpack\BackupManager\app\Http\Controllers\BackupController@download                   | web,admin
                                                           |
|        | GET|HEAD                               | admin/category                                     | admin.category.index           | App\Http\Controllers\Admin\CategoryCrudController@index                                 | web,admin,Closure                                                    |
|        | POST                                   | admin/category                                     | admin.category.store           | App\Http\Controllers\Admin\CategoryCrudController@store                                 | web,admin,Closure                                                    |
|        | POST                                   | admin/category/bulk-clone                          | admin.category.bulkClone       | App\Http\Controllers\Admin\CategoryCrudController@bulkClone                             | web,admin,Closure                                                    |
|        | POST                                   | admin/category/bulk-delete                         | admin.category.bulkDelete      | App\Http\Controllers\Admin\CategoryCrudController@bulkDelete                            | web,admin,Closure                                                    |
|        | PUT                                    | admin/category/create                              | admin.category.store           | App\Http\Controllers\Admin\CategoryCrudController@store                                 | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/category/create                              | admin.category.create          | App\Http\Controllers\Admin\CategoryCrudController@create                                | web,admin,Closure                                                    |
|        | POST                                   | admin/category/reorder                             | admin.category.save.reorder    | App\Http\Controllers\Admin\CategoryCrudController@saveReorder                           | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/category/reorder                             | admin.category.reorder         | App\Http\Controllers\Admin\CategoryCrudController@reorder                               | web,admin,Closure                                                    |
|        | POST                                   | admin/category/search                              | admin.category.search          | App\Http\Controllers\Admin\CategoryCrudController@search                                | web,admin,Closure                                                    |
|        | DELETE                                 | admin/category/{id}                                | admin.category.destroy         | App\Http\Controllers\Admin\CategoryCrudController@destroy                               | web,admin,Closure                                                    |
|        | PUT                                    | admin/category/{id}                                | admin.category.update          | App\Http\Controllers\Admin\CategoryCrudController@update                                | web,admin,Closure                                                    |
|        | POST                                   | admin/category/{id}/clone                          | admin.category.clone           | App\Http\Controllers\Admin\CategoryCrudController@clone                                 | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/category/{id}/details                        | admin.category.showDetailsRow  | App\Http\Controllers\Admin\CategoryCrudController@showDetailsRow                        | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/category/{id}/edit                           | admin.category.edit            | App\Http\Controllers\Admin\CategoryCrudController@edit                                  | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/category/{id}/revisions                      | admin.category.listRevisions   | App\Http\Controllers\Admin\CategoryCrudController@listRevisions                         | web,admin,Closure                                                    |
|        | POST                                   | admin/category/{id}/revisions/{revisionId}/restore | admin.category.restoreRevision | App\Http\Controllers\Admin\CategoryCrudController@restoreRevision                       | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/category/{id}/show                           | admin.category.show            | App\Http\Controllers\Admin\CategoryCrudController@show                                  | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/category/{id}/translate/{lang}               | admin.category.translateItem   | App\Http\Controllers\Admin\CategoryCrudController@translateItem                         | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/dashboard                                    | backpack.dashboard             | Backpack\CRUD\app\Http\Controllers\AdminController@dashboard                            | web,admin
                                                           |
|        | GET|HEAD                               | admin/elfinder                                     | elfinder.index                 | Barryvdh\Elfinder\ElfinderController@showIndex                                          | web,admin
                                                           |
|        | GET|HEAD                               | admin/elfinder/ckeditor                            | elfinder.ckeditor              | Barryvdh\Elfinder\ElfinderController@showCKeditor4                                      | web,admin
                                                           |
|        | GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS | admin/elfinder/connector                           | elfinder.connector             | Barryvdh\Elfinder\ElfinderController@showConnector                                      | web,admin
                                                           |
|        | GET|HEAD                               | admin/elfinder/filepicker/{input_id}               | elfinder.filepicker            | Barryvdh\Elfinder\ElfinderController@showFilePicker                                     | web,admin
                                                           |
|        | GET|HEAD                               | admin/elfinder/popup/{input_id}                    | elfinder.popup                 | Barryvdh\Elfinder\ElfinderController@showPopup                                          | web,admin
                                                           |
|        | GET|HEAD                               | admin/elfinder/tinymce                             | elfinder.tinymce               | Barryvdh\Elfinder\ElfinderController@showTinyMCE                                        | web,admin
                                                           |
|        | GET|HEAD                               | admin/elfinder/tinymce4                            | elfinder.tinymce4              | Barryvdh\Elfinder\ElfinderController@showTinyMCE4                                       | web,admin
                                                           |
|        | GET|HEAD                               | admin/elfinder/tinymce5                            | elfinder.tinymce5              | Barryvdh\Elfinder\ElfinderController@showTinyMCE5                                       | web,admin
                                                           |
|        | GET|HEAD                               | admin/log                                          |                                | Backpack\LogManager\app\Http\Controllers\LogController@index                            | web,admin
                                                           |
|        | DELETE                                 | admin/log/delete/{file_name}                       |                                | Backpack\LogManager\app\Http\Controllers\LogController@delete                           | web,admin
                                                           |
|        | GET|HEAD                               | admin/log/download/{file_name}                     |                                | Backpack\LogManager\app\Http\Controllers\LogController@download                         | web,admin
                                                           |
|        | GET|HEAD                               | admin/log/preview/{file_name}                      |                                | Backpack\LogManager\app\Http\Controllers\LogController@preview                          | web,admin
                                                           |
|        | POST                                   | admin/permission                                   | permission.store               | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@store          | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/permission                                   | permission.index               | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@index          | web,admin,Closure                                                    |
|        | PUT                                    | admin/permission/create                            | permission.store               | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@store          | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/permission/create                            | permission.create              | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@create         | web,admin,Closure                                                    |
|        | POST                                   | admin/permission/search                            | permission.search              | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@search         | web,admin,Closure                                                    |
|        | DELETE                                 | admin/permission/{id}                              | permission.destroy             | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@destroy        | web,admin,Closure                                                    |
|        | PUT                                    | admin/permission/{id}                              | permission.update              | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@update         | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/permission/{id}/details                      | permission.showDetailsRow      | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@showDetailsRow | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/permission/{id}/edit                         | permission.edit                | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@edit           | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/permission/{id}/translate/{lang}             | permission.translateItem       | Backpack\PermissionManager\app\Http\Controllers\PermissionCrudController@translateItem  | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/role                                         | role.index                     | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@index                | web,admin,Closure                                                    |
|        | POST                                   | admin/role                                         | role.store                     | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@store                | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/role/create                                  | role.create                    | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@create               | web,admin,Closure                                                    |
|        | PUT                                    | admin/role/create                                  | role.store                     | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@store                | web,admin,Closure                                                    |
|        | POST                                   | admin/role/search                                  | role.search                    | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@search               | web,admin,Closure                                                    |
|        | DELETE                                 | admin/role/{id}                                    | role.destroy                   | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@destroy              | web,admin,Closure                                                    |
|        | PUT                                    | admin/role/{id}                                    | role.update                    | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@update               | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/role/{id}/details                            | role.showDetailsRow            | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@showDetailsRow       | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/role/{id}/edit                               | role.edit                      | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@edit                 | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/role/{id}/translate/{lang}                   | role.translateItem             | Backpack\PermissionManager\app\Http\Controllers\RoleCrudController@translateItem        | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/setting                                      | setting.index                  | Backpack\Settings\app\Http\Controllers\SettingCrudController@index                      | web,admin,Closure                                                    |
|        | POST                                   | admin/setting/search                               | setting.search                 | Backpack\Settings\app\Http\Controllers\SettingCrudController@search                     | web,admin,Closure                                                    |
|        | PUT                                    | admin/setting/{id}                                 | setting.update                 | Backpack\Settings\app\Http\Controllers\SettingCrudController@update                     | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/setting/{id}/details                         | setting.showDetailsRow         | Backpack\Settings\app\Http\Controllers\SettingCrudController@showDetailsRow             | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/setting/{id}/edit                            | setting.edit                   | Backpack\Settings\app\Http\Controllers\SettingCrudController@edit                       | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/setting/{id}/translate/{lang}                | setting.translateItem          | Backpack\Settings\app\Http\Controllers\SettingCrudController@translateItem              | web,admin,Closure                                                    |
|        | POST                                   | admin/user                                         | user.store                     | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@store                | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/user                                         | user.index                     | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@index                | web,admin,Closure                                                    |
|        | PUT                                    | admin/user/create                                  | user.store                     | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@store                | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/user/create                                  | user.create                    | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@create               | web,admin,Closure                                                    |
|        | POST                                   | admin/user/search                                  | user.search                    | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@search               | web,admin,Closure                                                    |
|        | DELETE                                 | admin/user/{id}                                    | user.destroy                   | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@destroy              | web,admin,Closure                                                    |
|        | PUT                                    | admin/user/{id}                                    | user.update                    | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@update               | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/user/{id}/details                            | user.showDetailsRow            | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@showDetailsRow       | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/user/{id}/edit                               | user.edit                      | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@edit                 | web,admin,Closure                                                    |
|        | GET|HEAD                               | admin/user/{id}/translate/{lang}                   | user.translateItem             | Backpack\PermissionManager\app\Http\Controllers\UserCrudController@translateItem        | web,admin,Closure                                                    |
|        | GET|HEAD                               | category/{category}/{slug?}                        | category.index                 | App\Http\Controllers\Translation\CategoryController@index                               | web,auth,permission:Can View Translation                             |
|        | GET|HEAD                               | login                                              | login                          | App\Http\Controllers\Auth\LoginController@showLoginForm                                 | web,guest
                                                           |
|        | POST                                   | login                                              |                                | App\Http\Controllers\Auth\LoginController@login                                         | web,guest
                                                           |
|        | POST                                   | logout                                             | logout                         | App\Http\Controllers\Auth\LoginController@logout                                        | web
                                                           |
|        | POST                                   | password/confirm                                   |                                | App\Http\Controllers\Auth\ConfirmPasswordController@confirm                             | web,auth
                                                           |
|        | GET|HEAD                               | password/confirm                                   | password.confirm               | App\Http\Controllers\Auth\ConfirmPasswordController@showConfirmForm                     | web,auth
                                                           |
|        | POST                                   | password/email                                     | password.email                 | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail                   | web,guest
                                                           |
|        | GET|HEAD                               | password/reset                                     | password.request               | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm                  | web,guest
                                                           |
|        | POST                                   | password/reset                                     | password.update                | App\Http\Controllers\Auth\ResetPasswordController@reset                                 | web,guest
                                                           |
|        | GET|HEAD                               | password/reset/{token}                             | password.reset                 | App\Http\Controllers\Auth\ResetPasswordController@showResetForm                         | web,guest
                                                           |
|        | POST                                   | search/team                                        |                                | App\Http\Controllers\SearchController@teamSearch                                        | web,auth,permission:Can Search,permission:Can View Team              |
|        | POST                                   | search/translation                                 |                                | App\Http\Controllers\SearchController@translationSearch                                 | web,auth,permission:Can Search,permission:Can View Translation       |
|        | POST                                   | search/user                                        |                                | App\Http\Controllers\SearchController@userSearch                                        | web,auth,permission:Can Search,permission:Can View User              |
|        | GET|HEAD                               | social/handle/{provider}                           | social.handle                  | App\Http\Controllers\Auth\SocialController@getSocialHandle                              | web
                                                           |
|        | GET|HEAD                               | social/redirect/{provider}                         | social.redirect                | App\Http\Controllers\Auth\SocialController@getSocialRedirect                            | web
                                                           |
|        | GET|HEAD                               | team                                               | team.index                     | App\Http\Controllers\TeamController@index                                               | web,auth,permission:Can View Team,Closure                            |
|        | GET|HEAD                               | team/create                                        | team.create                    | App\Http\Controllers\TeamController@create                                              | web,auth,permission:Can View Team,permission:Can Create Team,Closure |
|        | POST                                   | team/create                                        | team.store                     | App\Http\Controllers\TeamController@store                                               | web,auth,permission:Can View Team,permission:Can Create Team,Closure |
|        | GET|HEAD                               | team/{slug}                                        | team.show                      | App\Http\Controllers\TeamController@show                                                | web,auth,permission:Can View Team,Closure                            |
|        | GET|HEAD                               | team/{slug}/avatar/{image}                         | team.avatar                    | App\Http\Controllers\TeamController@showAvatar                                          | web,auth,permission:Can View Team,Closure                            |
|        | POST                                   | team/{slug}/destroy                                | team.destroy                   | App\Http\Controllers\TeamController@destroy                                             | web,auth,permission:Can View Team,Closure                            |
|        | GET|HEAD                               | team/{slug}/edit                                   | team.edit                      | App\Http\Controllers\TeamController@edit                                                | web,auth,permission:Can View Team,Closure                            |
|        | GET|HEAD                               | team/{slug}/join                                   | team.join                      | App\Http\Controllers\TeamController@join                                                | web,auth,permission:Can View Team,Closure                            |
|        | POST                                   | team/{slug}/leave                                  | team.leave                     | App\Http\Controllers\TeamController@leave                                               | web,auth,permission:Can View Team,Closure                            |
|        | POST                                   | team/{slug}/sendInvite                             | team.sendInvite                | App\Http\Controllers\TeamController@sendInvite                                          | web,auth,permission:Can View Team,Closure                            |
|        | POST                                   | team/{slug}/update                                 | team.update                    | App\Http\Controllers\TeamController@update                                              | web,auth,permission:Can View Team,Closure                            |
|        | GET|HEAD                               | translation/{id}                                   | translation.show               | App\Http\Controllers\Translation\TranslationController@show                             | web,auth,permission:Can View Translation                             |
+--------+----------------------------------------+----------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------+----------------------------------------------------------------------+

@pxpm
Copy link
Contributor

pxpm commented Mar 9, 2020

Try clearing your cache @shbov php artisan route:cache

@shbov
Copy link
Author

shbov commented Mar 9, 2020

Tried, same result.

@tabacitu
Copy link
Member

tabacitu commented Mar 9, 2020

Hmmm this is indeed weird. Yes you do have two routes with the same route name. All CRUDs do. Sidenote: this makes me wonder why we don't just remove one of them - opened an issue for it here.


But. The fact that there are two routes with the same name should NOT trigger an error. It does not do so for me. And it does not do so for @pxpm . So it's very weird... I'm sorry @shbov but I don't know if I can be of any more help in this matter - might be a local env thing... or a matter of using a certain package that hooks into the optimize command... something like that... I don't know...

@lotarbo
Copy link
Contributor

lotarbo commented Mar 9, 2020

@tabacitu i have same error. fresh laravel with backpack and some new crud, generated with command.
When i run php artisan route:cache i have error.
Unable to prepare route [admin/film] for serialization. Another route has already been assigned name [film.store].

I use docker with image php:7.4-fpm-alpine
My route file - routes/backpack/custom.php

Route::group([
    'prefix'     => config('backpack.base.route_prefix', 'admin'),
    'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
    'namespace'  => 'App\Http\Controllers\Admin',
], function () { // custom admin routes
    Route::crud('film', 'FilmCrudController');
    Route::crud('producer', 'ProducerCrudController');
    Route::crud('actor', 'ActorCrudController');
    Route::crud('country', 'CountryCrudController');
}); // this should be the absolute last line of this file

same name store


/var/www # php artisan backpack:version
### PHP VERSION:
PHP 7.4.3 (cli) (built: Feb 20 2020 21:53:46) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

### LARAVEL VERSION:
v7.0.8@d71ba61d51aec79a0a0f907991ec215dc24b09d4

### BACKPACK VERSION:
4.0.51@aaf10ec658d1abf4f20d73575dc1d1a13c97cf5d

@pxpm
Copy link
Contributor

pxpm commented Mar 9, 2020

I am so sorry for closing this.

I am still not 100% sure what is causing this, but I can confirm it's happening.

Route::group([
    'prefix'     => config('backpack.base.route_prefix', 'admin'),
    'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
    'namespace'  => 'App\Http\Controllers\Admin',
], function () { // custom admin routes
     Route::crud('test', 'TestCrudController');
}); // this should be the absolute last line of this file

Gives me the error:

Unable to prepare route [admin/test] for serialization. Another route has already been assigned name [test.store]

I am re-opening this, and I need to dig deeper.

If anyone else found a solution, please let us know.

@pxpm pxpm reopened this Mar 9, 2020
@pxpm pxpm added the Bug label Mar 9, 2020
@triage-new-issues triage-new-issues bot removed the triage label Mar 9, 2020
@pxpm pxpm changed the title Unable to prepare route for serialization. [4.0][BUG] Unable to prepare route for serialization. Mar 9, 2020
@lotarbo
Copy link
Contributor

lotarbo commented Mar 9, 2020

@pxpm #2525
remove PUT route helps me

@pxpm
Copy link
Contributor

pxpm commented Mar 9, 2020

As me and @tabacitu already suspected.

Dunno why now it's complaining, we are just going to make sure we don't use the route anywhere like #2525

@lotarbo indeed, I have also confirmed that removing the PUT route ends the problem.

I think it's safe to remove because we are not using it, we use the POST one.

I will open a PR for it.

Thank you all for the input, it really helped to tackle this one down.

@lotarbo
Copy link
Contributor

lotarbo commented Mar 9, 2020

@pxpm looks like this is new https://github.com/laravel/framework/blob/a85f93244ae46a6542409c4296da6764795be14d/src/Illuminate/Routing/AbstractRouteCollection.php#L199
in laravel 7

@tabacitu
Copy link
Member

tabacitu commented Mar 9, 2020

#2529 is now merged and tagged. So a composer update should fix this for you guys. Let us know if it doesn't, and we'll reopen the issue.

@azaricstefan
Copy link
Contributor

Hi @pxpm @tabacitu
With latest backpack/crud I am getting this error when I execute php artisan optimize.

LogicException

Unable to prepare route [password/reset] for serialization. Another route has already been assigned name [password.request].

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▕

  +30 vendor frames 

31 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

PHP VERSION:

PHP 7.4.9 (cli) (built: Aug 7 2020 19:23:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
with Zend OPcache v7.4.9, Copyright (c), by Zend Technologies

LARAVEL VERSION:

v8.25.0@05da44d6823c2923597519ac10151f5827a24f80

BACKPACK VERSION:

4.1.32@1a65e15562989c8fda3d2941da7110ca4008e21e

@pxpm
Copy link
Contributor

pxpm commented Feb 4, 2021

Hello @azaricstefan

Most probably you are using 2 auth systems, and both define the same password.request route?

Maybe using laravel auth + backpack auth ?

Try changing the name of laravel route (to avoid overwritting backpack).

Let me know,
Pedro

@azaricstefan
Copy link
Contributor

Laravel auth is defined with:
Auth::routes();

How could I change the name?

Why would this be an issue if backpack has prefix for his routes?

@azaricstefan
Copy link
Contributor

Hmm, I just checked routes with this name and it looks like it's not related to Backpack after all.
Did this: php artisan route:list --name=password.request

Screenshot 2021-02-09 at 22 45 17

Just to write how I resolved it -> I removed nascent-africa/jetstrap from composer.json since I am not using it still.

Thanks for replying btw, @pxpm.

@CtrlShiftN
Copy link

Thank to Auth::routes(); we know this err.
BCause we have two same things:

require __DIR__ . '/auth.php';
Auth::routes();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants