In a typical Laravel application we are very used to doing things in a certain way, by the book as they say. However there comes a point in the applications lifetime that it is going to be easier to start looking to split this code into Domains so that we can logically group our code.

The next thing we want to make sure that we do is create a Service Provider for each domain.

An example of the Service Provider will look like this: [ // All others that come with Laravel /* * Domain Service Providers */ Domains\Communication\Providers\CommunicationServiceProvider::class, Domains\Blogging\Providers\BloggingServiceProvider::class, Domains\Work\Providers\WorkServiceProvider::class, ]]; This allows us, using configuration, to turn domains on and off simply by commenting our the service provider.

Now that we have our domains being loaded through composer, and our Laravel application is aware of the service providers for each domain - we are ready to write actual domain code.
Newsletter

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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners