I'm using the map function in the RouteServiceProvider to manipulate some routes before are being processed any further.
When I run on my local machine everything runs fine but on the production server for some reason non of the map functions are being called.
To make sure the bug was not for some reason in my own code I used the orignal RouteServiceProvider.php with just some echo's added for testing purposes:
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
echo 'RouteServiceProvider boot';
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
echo 'RouteServiceProvider map';
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
echo 'RouteServiceProvider mapWebRoutes';
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
echo 'RouteServiceProvider mapApiRoutes';
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
When running on production server I get:
RouteServiceProvider boot
When running on local machine:
RouteServiceProvider bootRouteServiceProvider mapRouteServiceProvider mapApiRoutesRouteServiceProvider mapWebRoutes
So it seems on the production server the class is perfectly loaded and the boot function also is called but the none of the map function are.
I've tried clearing every type of cache but the result remained the same. However during the cache clear it DOES call all the map functions:
php artisan route:cache
RouteServiceProvider bootRoute cache cleared!
RouteServiceProvider bootRouteServiceProvider mapRouteServiceProvider mapApiRoutesRouteServiceProvider mapWebRoutesRoutes cached successfully!
Any idea what might be causing this or how to resolve it?
PS On the production server everything is deployed using PHP Deployer, but everything else is running fine so I assume that's not the issue.