Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

manuel03's avatar

Some Routes not working after upgrade to laravel 8

Hello!

Im upgrading an old laravel project right now from 7 to 8 and im having some problems... its not my project originally and im quite new to laravel so please excuse stupid questions :D

the problem is, that some Routes are not working after the upgrade. I changed the $namespace Setting in the "RouteServiceProvider.php" file according to the upgrade guide!

these Routes are working perfectly:

Route::get("/niederoesterreich/kontakt", 'HomeController@Grid');

Route::get("/print/{id}", array( "as"=>"printevent", "uses"=>"EventController@PrintEvent" ));

Route::get("/{id}/{title}", array( "as"=>"event", "uses"=>"EventController@getIndex" ));

Route::get("/Event/{id}/{title}", array( "as"=>"event", "uses"=>"EventController@getIndex" ));

but these arent:

Route::any('/Home/LIST', 'HomeController@ListAction');

Route::any('Share', 'EventController@Share');

Route::get('DateTimeframes', 'HomeController@DateTimeframes');

has someone any idea why they arent working? thanks a lot

0 likes
9 replies
gych's avatar

The way your writing your routes is deprecated and this might be the reason why some of the routes are not working. In Laravel 8 you should write your routes like this

Route::any('/home/list', [HomeController::class, 'listAction']);
Route::any('share', [EventController::class, 'share']);
Route::get('datetimeframes', [HomeController::class, 'dateTimeframes']);

Also apply this to your other routes that are still working, you can find more info in the docs: https://laravel.com/docs/8.x/routing

1 like
manuel03's avatar

Hi! Sry i should have written that i already tried the buggy Routes with the new syntax.

Route::get('Datetimeframes', [HomeController::class, 'DateTimeframes']);

didn't help me im still getting 404

1 like
manuel03's avatar

here is the whole web file with some routes cencored. maybe it helps there are some parts that i don't understand and that maybe cause problems


<?php
use App\Http\Models\SearchCriteria as SearchCriteria;
use App\Http\Helpers\ViewModel as ViewModel;
use App\Http\Models\ListOption as ListOption;
use App\Http\Controllers\HomeController;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Response;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

/**
 * SEO Urls doesn't work in iFrame, so remove the URL from this pattern
 */
Route::pattern('domain', '(---------|cluster|cluster.ddev.site|cluster.ddev.local|-------)');
Route::group(['domain' => '{domain}'], function() {

  // filtering from homepage
  Route::post('/', function($listoption){
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting');
  });

  // filtering from list view
  Route::post('list', function($listoption){
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting',["listoption" => "list"]);
  });

  // filtering from grid view
  Route::post('grid', function($listoption){
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting',["listoption" => "grid"]);
  });

  // filtering from map view
  Route::post('map', function($listoption){
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting',["listoption" => "map"]);
  });
  
  // filtering from an already filtered page, indicated by /s/... with any number of parameters
  Route::post('/s/{any?}', function() {
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting');
  })->where('any', '.*');

  // filtering from an already filtered page, indicated by list/s/... with any number of parameters
  Route::post('list/s/{any?}', function() {
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting',["listoption" => "list"]);
  })->where('any', '.*');

  // filtering from an already filtered page, indicated by grid/s/... with any number of parameters
  Route::post('grid/s/{any?}', function() {
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting',["listoption" => "grid"]);
  })->where('any', '.*');

  // filtering from an already filtered page, indicated by grid/s/... with any number of parameters
  Route::post('map/s/{any?}', function() {
    return App::call('App\Http\Controllers\HomeController@handlePRGRouting',["listoption" => "map"]);
  })->where('any', '.*');

  // get routes of prg-pattern for list view
  Route::get('list/s/{p1?}/{p2?}/{p3?}/{p4?}/{p5?}/{p6?}/{p7?}/{p8?}/{p9?}/{p10?}/{p11?}/{p12?}/{p13?}/{p14?}/{p15?}/{p16?}', array(
    "as"=>"setQueryParametersList",
    "uses"=>"HomeController@setQueryParametersList"
  ));

  // get routes of prg-pattern for grid view
  Route::get('grid/s/{p1?}/{p2?}/{p3?}/{p4?}/{p5?}/{p6?}/{p7?}/{p8?}/{p9?}/{p10?}/{p11?}/{p12?}/{p13?}/{p14?}/{p15?}/{p16?}', array(
    "as"=>"setQueryParameters",
    "uses"=>"HomeController@setQueryParameters"
  ));

  // get routes of prg-pattern for grid view
  Route::get('map/s/{p1?}/{p2?}/{p3?}/{p4?}/{p5?}/{p6?}/{p7?}/{p8?}/{p9?}/{p10?}/{p11?}/{p12?}/{p13?}/{p14?}/{p15?}/{p16?}', array(
    "as"=>"setQueryParametersMap",
    "uses"=>"HomeController@setQueryParametersMap"
  ));

  // get routes of prg-pattern for home view
  Route::get('/s/{p1?}/{p2?}/{p3?}/{p4?}/{p5?}/{p6?}/{p7?}/{p8?}/{p9?}/{p10?}/{p11?}/{p12?}/{p13?}/{p14?}/{p15?}/{p16?}', array(
    "as"=>"setQueryParameters",
    "uses"=>"HomeController@setQueryParameters"
  ));

});


//Locations
Route::pattern('domainLocations', '(........)');
Route::group(['domain' => '{domainLocations}'], function() {
  Route::get("/{id}/{title}", "LocationController@Detail");
  Route::any("/", "LocationController@Index");
});


Route::get("googled082a64affbd4ff3.html",function() {
  return File::get(public_path() . '/js/googled082a64affbd4ff3.html');
});
Route::get("sitemap.xml",function() {
  return Response::make(File::get(public_path() . '/assets/sitemap.xml'), 200, ['Content-type'=>'text/xml']);
});

Route::get('/wf/13D54FE32AB2309FC241AFD9734D2193', 'SitemapController@SitemapXML');



Route::get("/print/{id}", array(
    "as"=>"printevent",
    "uses"=>"EventController@PrintEvent"
));

Route::get("/{id}/{title}", array(
    "as"=>"event",
    "uses"=>"EventController@getIndex"
));
Route::get("/Event/{id}/{title}", array(
    "as"=>"event",
    "uses"=>"EventController@getIndex"
));
Route::get("/Home/Event/{id}", array(
    "as"=>"event",
    "uses"=>"EventController@getIndex"
));

Route::get("/{id}", array(
    "as"=>"event",
    "uses"=>"EventController@getIndex"
));
Route::get("/Event/{id}", array(
    "as"=>"event",
    "uses"=>"EventController@getIndex"
));


//Route::any('test', 'HomeController@Test');
Route::any('/Home/List', 'HomeController@ListAction');
Route::any('/home/LIST', 'HomeController@ListAction');
Route::any('/home/list', 'HomeController@ListAction');
Route::any('/Home/LIST', 'HomeController@ListAction');
Route::any('list', 'HomeController@ListAction');

Route::any('/Home/Index', 'HomeController@Grid');
Route::any('/Home/Grid', 'HomeController@Grid');
Route::any('/home/grid', 'HomeController@Grid');
Route::any('grid', 'HomeController@Grid');

Route::any('_list', 'HomeController@_List');
Route::any('_grid', 'HomeController@_Grid');
Route::any('map', 'HomeController@Map');
Route::any('MapData', 'HomeController@MapData');
Route::any('Share', 'EventController@Share');
Route::any('Contact', 'EventController@Contact');
//Route::any('ShareSearch', 'EventController@ShareSearch');
Route::any('Report', 'EventController@Report');
Route::get('DateTimeframes', 'HomeController@DateTimeframes');
Route::any('NearestPlaces', 'EventController@NearestPlaces');

Route::any('7d4bd500eb06434faf65f21829a8525e','HookController@PostCommit');

Route::get("/shorten/{params}", array(
	"as"=>"shorten",
	"uses"=>"HomeController@Shorten"
));

/*
Route::any('NearestPlaces(:any)', function($client, $action)
{
	dd($action);
    return Controller::call('EventController@NearestPlaces',array($action));
});
*/

Route::any("/Series/{id}", array(
    "as"=>"Series",
    "uses"=>"HomeController@Series"
));
Route::get("/Home/Series/{id}", array(
    "as"=>"Series",
    "uses"=>"HomeController@Series"
));
Route::get("/Home/Series/{id}/{title}", array(
  "as"=>"Series",
  "uses"=>"HomeController@Series"
));
Route::any("/Series/{id}/{title}", array(
  "as"=>"Series",
  "uses"=>"HomeController@Series"
));


Route::get("/place/{id}", array(
    "as"=>"place",
    "uses"=>"HomeController@Place"
));
Route::get("/place/{id}/{title}", array(
  "as"=>"place",
  "uses"=>"HomeController@Place"
));

Route::any('_Subcategories', 'SearchController@_Subcategories');
Route::any('Communities', 'SearchController@Communities');
Route::any('CommunityID', 'SearchController@CommunityID');


Route::domain('------------')->group(function () {

  Route::prefix('/cal/{slug?}')->group(function () { 
    
    Route::get("/{id}/{title}", array(
      "as"=>"event",
      "uses"=>"EventController@getIndex"
    ));

    Route::any('grid', 'HomeController@Grid');
    Route::any('_grid', 'HomeController@_Grid');
    Route::any('list', 'HomeController@ListAction');
    Route::any('_list', 'HomeController@_List');
    Route::any('map', 'HomeController@Map');
    Route::any('MapData', 'HomeController@MapData');
    Route::any('DateTimeframes', 'HomeController@DateTimeframes');
    Route::get("/Series/{id}/{title}", "HomeController@Series");
    //Route::any('Share', 'EventController@Share'); do not activate - normal route is working?!
    Route::get("print/{id}", "EventController@PrintEvent" );
    Route::any("/", "HomeController@Grid");

  });

});

Route::any("/", array(
  "as"=>"Index",
  "uses"=>"HomeController@Index"
));
gych's avatar

Which of these routes are not working? Only the ones you mentioned in your initial post?

Also avoid this

Route::any('/Home/List', 'HomeController@ListAction');
Route::any('/home/LIST', 'HomeController@ListAction');
Route::any('/home/list', 'HomeController@ListAction');
Route::any('/Home/LIST', 'HomeController@ListAction');

Just use a single route with no capitals

Route::any('/home/list', [HomeController::class, 'ListAction']);

How are you accessing the routes and when you try to access the not working routes which error do you get?

manuel03's avatar

i know after the update i have to cleanup this.... like i said old project and not mine originally :D

some working routes are for example '/'

or these

Route::any("/Series/{id}", array(
    "as"=>"Series",
    "uses"=>"HomeController@Series"
));

or this one '/s/t/heute/sortiert-nach-empfehlung'

right now calling the route just in the browser(firefox) parallel i have the old live system to check. there the routes are working. im getting a 404 for the routes right now.

this whole block for example is not working (old and new syntax)

Route::any('/Home/List', 'HomeController@ListAction');
Route::any('/home/LIST', 'HomeController@ListAction');
Route::any('/home/list', 'HomeController@ListAction');
Route::any('/Home/LIST', 'HomeController@ListAction');
Route::any('list', 'HomeController@ListAction');

Route::any('/Home/Index', 'HomeController@Grid');
Route::any('/Home/Grid', 'HomeController@Grid');
Route::any('/home/grid', 'HomeController@Grid');
Route::any('grid', 'HomeController@Grid');

Route::any('_list', 'HomeController@_List');
Route::any('_grid', 'HomeController@_Grid');
Route::any('map', 'HomeController@Map');
Route::any('MapData', 'HomeController@MapData');
Route::any('Share', 'EventController@Share');
Route::any('Contact', 'EventController@Contact');
//Route::any('ShareSearch', 'EventController@ShareSearch');
Route::any('Report', 'EventController@Report');
Route::get('DateTimeframes', 'HomeController@DateTimeframes');
Route::any('NearestPlaces', 'EventController@NearestPlaces');

and some other very weird problems are:

this one works right:

Route::any("/Series/{id}/{title}", array(
  "as"=>"Series",
  "uses"=>"HomeController@Series"
));

but this one gives me a 404

Route::any("/Series/{id}", array(
    "as"=>"Series",
    "uses"=>"HomeController@Series"
));
gych's avatar

Run this command in your terminal, maybe some of your routes are cached

php artisan route:clear

For testing purposes try to add this at the top in your routes file.

Route::get('/home/list', function () {
    return 'Home List Route Works';
});

Does it return the message Home List Route Works ?

amitsolanki24_'s avatar

Try to remove all your routes from web.php file for just testing and check routes thats are giving 404 one by one.

manuel03's avatar

the route clearing doesn't help sadly.

funny thing, when i add this code at the start of the file the route works again. But it doesn't return the text 'Home List Route Works' but the 'HomeController@ListAction' that is further down in the file. so adding the wrong code somehow makes it that the correct code later works ...

Route::get('/home/list', function () {
    return 'Home List Route Works';
});

i will probably have no other choice but to remove and re add all routes step by step i just had hoped for an easy fix :D

gych's avatar

@manuel03 I think that would be best, just create a new file and slowly add your routes one by one. Try to avoid using any when not necessary use get,post,put,patch,delete for your routes or resource route. Also update your routes to the curent route format, not the old format that is currently used for your routes..

https://laravel.com/docs/11.x/routing#the-default-route-files

If you want to use resource route, here is an example from the docs how they work https://laravel.com/docs/11.x/controllers#actions-handled-by-resource-controllers

Please or to participate in this conversation.