rifatxtra / feature-based-laravel
A feature-based Laravel template with Inertia.js, React, Tailwind, Breeze, and Sanctum for scalable modular web applications.
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
pkg:composer/rifatxtra/feature-based-laravel
Requires
- php: ^8.2
- inertiajs/inertia-laravel: ^2.0
- laravel/framework: ^12.0
- laravel/sanctum: ^4.0
- laravel/tinker: ^2.10.1
- tightenco/ziggy: ^2.0
Requires (Dev)
- fakerphp/faker: ^1.23
- laravel/breeze: ^2.3
- laravel/pail: ^1.2.2
- laravel/pint: ^1.24
- laravel/sail: ^1.41
- mockery/mockery: ^1.6
- nunomaduro/collision: ^8.6
- phpunit/phpunit: ^11.5.3
README
This Laravel template uses feature-based architecture for clean, modular, and scalable development.
Project Overview
- 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.
Installation / How to Use
Step 1: Clone the Template
git clone https://github.com/rifatxtra/feature-based-laravel my-project
cd my-project
Step 2: Install PHP Dependencies
composer install
Step 3: Install Node Dependencies
npm install
Step 4: Create .env File
cp .env.example .env php artisan key:generate
Step 5: Run Migrations (Optional)
php artisan migrate
Step 6: Start the Development Server
php artisan serve npm run dev
Adding New Features
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.
Using Inertia Pages
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.
Notes
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:
php artisan route:cache
What We Changed from Default Laravel
🧩 Feature-Based Architecture
- 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.
🛣️ Routing
- 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.
🎨 Frontend
- Pages folder renamed from
Pages→Features. - Fully compatible with Inertia + React + Tailwind.
- Each feature can contain multiple pages and components.
⚙️ Global Resources
- Middleware, Jobs, and Mailables remain global.
- Feature folders contain only feature-specific logic.
- Shared resources remain untouched.
🚀 Scalability
- Each feature is modular (backend + frontend).
- Easy to add new features without touching unrelated code.
- Supports converting features into reusable packages.