This Laravel template uses feature-based architecture for clean, modular, and scalable development.
- Each feature has its own Controllers, Models, Requests, Services, Routes.
- Web and API routes are auto-loaded via
RouteServiceProvider. - Frontend pages are organized by feature under
resources/js/Features/. - Uses Breeze + React + Tailwind + Inertia for SPA pages.
- Default
routes/folder is removed.
git clone https://github.com/rifatxtra/feature-based-laravel my-project
cd my-projectcomposer installnpm installcp .env.example .env
php artisan key:generatephp artisan migratephp artisan serve
npm run dev1.Create a feature folder inside app/Features/:
app/Features/FeatureName/
├── Controllers/
├── Models/
├── Requests/
├── Services/
├── routes.php
└── api.php2.Create frontend pages in:
resources/js/Features/FeatureName/3.Define web routes in routes.php and API routes in api.php. These are auto-loaded via RouteServiceProvider.
4.Create Controllers extending App\Http\Controllers\Controller.
5.Optionally create Requests and Services for validation and business logic.
Frontend pages live in:
resources/js/Features/FeatureName/PageName.jsx
In the controller:
return Inertia::render('FeatureName/PageName', [
'title' => 'My Page',
]);Routes automatically map to this page.
No routes/ folder is needed — all routes are in features.
Web and API routes are separated.
Middleware, Jobs, Mailables are kept global (not per feature).
Fully compatible with Laravel route caching:
- Converted Laravel to feature-based structure.
- Removed default
routes/folder. - Added
app/Features/for Controllers, Models, Requests, Services, and feature-specific routes. - Frontend pages moved to
resources/js/Features/instead ofPages.
- All web and API routes are auto-loaded via
RouteServiceProvider. - No need to manually update
bootstrap/app.php. - Web routes use
'web'middleware, API routes use'api'prefix.
- Pages folder renamed from
Pages→Features. - Fully compatible with Inertia + React + Tailwind.
- Each feature can contain multiple pages and components.
- Middleware, Jobs, and Mailables remain global.
- Feature folders contain only feature-specific logic.
- Shared resources remain untouched.
- Each feature is modular (backend + frontend).
- Easy to add new features without touching unrelated code.
- Supports converting features into reusable packages.