Custom Routes with Laravel 7

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
flomo
Posts: 52
Joined: 26 Sep 2019, 15:11

Custom Routes with Laravel 7

Post by flomo » 08 Apr 2020, 16:07

As of Laravel 7 it is no longer possible to have duplicate route names: https://laravel.com/docs/7.x/upgrade#unique-route-names

The Aimeos docs recommend to add a duplicate route to overwrite the default URLs: https://aimeos.org/docs/Laravel/Custom_routes

This fails in Laravel 7 when using

Code: Select all

php artisan optimize
What is the best practice to have custom routes with Laravel 7?

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Custom Routes with Laravel 7

Post by aimeos » 09 Apr 2020, 15:32

That does complicate things a bit.

You can disable the Aimeos routes for the area you want to overwrite a route for by configuration:
https://github.com/aimeos/aimeos-larave ... s.php#L181

Then, you have to add all the routes you've disabled yourself and change the one you want.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

flomo
Posts: 52
Joined: 26 Sep 2019, 15:11

Re: Custom Routes with Laravel 7

Post by flomo » 09 Apr 2020, 15:53

I did something similar in my web.php routes file:

Code: Select all

// Clear previous routes
$emptyRoutes = new \Illuminate\Routing\RouteCollection();
Route::setRoutes($emptyRoutes);

// Add modified content from Aimeos routes.php
Maybe it's best, if one could simply "php artisan vendor:publish --tag=aimeos_routes", to expose and modify Aimeos routes. Just not sure, if this poses maintainability issues (ie if you make changes to the routes.php file on minor version changes).

Post Reply