Recently I came across a unique approach to loading routes into Laravel applications, and I wanted to share this with you. It allows you to create Route Registrars classes you register your routes within.

We make a few changes to the Route Service Provider - and remove the web and API route files.

{ $registrar->view('/', 'welcome'); Now that our default registrar is created, we can register this inside our Route Service Provider, ensuring it is loaded.

As an example, I would imagine the route service provider looking like the following: declare(strict_types=1); namespace App\Providers; use App\Routing\Concerns\MapsRouteRegistrars; use App\Routing\Registrars\AdminRegistrar; use App\Routing\Registrars\BlogRegistrar; use App\Routing\Registrars\MarketingRegistrar; use Illuminate\Contracts\Routing\Registrar; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class RouteServiceProvider extends ServiceProvider { use MapsRouteRegistrars; protected array $registrars = [
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners