Somewhere in docs he covers the order of things in the laravel cycle, the boot method may be too early for the route in cycle.
Apr 15, 2021
11
Level 4
Load Routes from a Service Provider
Hello Team. I created a new service provider.
In the boot method i call migrations and a route file. The migrations works, but for the routes, i get the error, failed to open stream.
php artisan route:list --compact
The routes are there! But it will not work.
<?php
namespace App\Providers\Schema;
use Illuminate\Support\ServiceProvider;
class OrganizationServiceProvider extends ServiceProvider
{
public function register()
{
//
}
public function boot()
{
$this->loadMigrationsFrom('database/migrations/organization');
$this->loadRoutesFrom('routes/organization/web.php');
}
}
The Migration works, but not the route file. Many thanks for help :)
Level 15
In this case $this->loadRoutesFrom(base_path('routes/organization/web.php')); will work just fine. 👍
1 like
Please or to participate in this conversation.