| Install | |
|---|---|
composer require rifatxtra/feature-based-laravel |
|
| Latest Version: | v1.0.0 |
| PHP: | ^8.2 |
This Laravel template uses feature-based architecture for clean, modular, and scalable development.
RouteServiceProvider.resources/js/Features/.routes/ folder is removed.git clone https://github.com/rifatxtra/feature-based-laravel my-project
cd my-project
composer install
npm install
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan serve
npm run dev
1.Create a feature folder inside app/Features/:
app/Features/FeatureName/
├── Controllers/
├── Models/
├── Requests/
├── Services/
├── routes.php
└── api.php
2.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:
routes/ folder.app/Features/ for Controllers, Models, Requests, Services, and feature-specific routes.resources/js/Features/ instead of Pages.RouteServiceProvider.bootstrap/app.php.'web' middleware, API routes use 'api' prefix.Pages → Features.