You got the path wrong.
Error: require(webhook): Failed to open stream: No such file or directory
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In Laravel 8 it was possible to include additional route files with the require base_path parameter
//routes/web.php
Route::middleware(['web'])->group(function () { require base_path('routes/link/webhook.php'); });
php artisan route:cache responds that
Error: require(webhook): Failed to open stream: No such file or directory
This fails to work with require . DIR . '/link/webhook.php'; as well
Error: require(webhook): Failed to open stream: No such file or directory
The documentation recommends using the app.php function
// laravel.com/docs/12.x/routing - bootstrap/app.php
use Illuminate\Support\Facades\Route;
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
then: function () {
Route::middleware('web')
->group(base_path('routes/link/webhooks.php'));
},
)
php artisan route:cache responds
Error: require(webhook): Failed to open stream: No such file or directory
an ls -s routes/link/webhook.php responds with the filename and I have already tried to chmod -R 777 routes and chown -R user:user routes
When the path is made incorrect it lists the entire incorrect path: require base_path('routeslink/webhook.php');
/var/www/html/laravel-project/routeslink/webhook.php cannot be found but when fixed it returns
Error: require(webhook): Failed to open stream: No such file or directory
I have also tried listing the route in the RouteServiceProvider by the same syntax but it still returns
Error: require(webhook): Failed to open stream: No such file or directory
If i remove all requires and changes to the bootstrap/app.php and RouteServiceProvider.php php artisan route:cache works well.
I have also tried to composer dump-autoload php artisan cache:clear
But the app is still unable to find the existing additional route file How can I fix this error?
Please or to participate in this conversation.