Source: juststeveking-uk-astro.pages.dev

Laravel DDD - Routing within our Domain
In a normal Laravel application we store all of our routes within web.php or api.php typically, however how does this work with our Domain Driven Design approach? My typical approach with this scenario is to create a routes file per domain, and store this within the domain itself. We can then use our Domains Service Provider to register our routes, and they will then be enabled and disabled simply by removing the domain service provider. This makes each domain able to be completely removed simply by using the service providers. Let us start with the Blogging Domain API again, and create the routes file, create the following file src/Domains/Blogging/Routes/Api/v1.php and add the following: as('api:v1:')->group(function () {
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