Installation & Setup
Get up and running with nagibmahfuj/laravel-inertia-crud v2 in minutes.
Requirements
| Dependency | Supported Versions |
|---|---|
| PHP | ^8.2 |
| Laravel | 11.x, 12.x, or 13.x |
| Inertia.js | ^1.0, ^2.0, or ^3.0 |
| React | 18+ or 19+ |
| Node.js | 18+ |
Frontend Prerequisites
Your Laravel React/TypeScript app should include:
- shadcn/ui components:
Badge,Button,Calendar,Card,Checkbox,Command,Dialog,DropdownMenu,Input,Label,Popover,Progress,Select,Separator,Table,Textarea - lucide-react — Icons
- date-fns — Date formatting
- clsx & tailwind-merge — Class merging
- lodash — Nested object lookup (
get) - react-day-picker (v9 / v10) — Calendar and date-range pickers
Step 1: Install via Composer
composer require nagibmahfuj/laravel-inertia-crud:^2.0Fresh Laravel Starter Kits with Laravel Boost
Recent Laravel starter kits include laravel/boost with @php artisan boost:update --ansi in composer.json's post-update-cmd. On a brand-new project where Boost hasn't been initialized yet, composer require may stop with Please set up Boost with [php artisan boost:install] first. (and leave "*" in composer.json if no version constraint was passed).
Run php artisan boost:install once first (which also auto-discovers this package's resources/boost/ AI guidelines & skill), or remove the boost:update hook if you don't use Boost, then run composer require nagibmahfuj/laravel-inertia-crud:^2.0.
Laravel auto-discovers NagibMahfuj\Crud\CrudServiceProvider, registering:
Route::crudResource()macro- Native chunk upload endpoints (
POST /crud/chunk-upload,DELETE /crud/chunk-upload/{uploadId}) - Native async relationship options endpoint (
GET /crud/options) - Native background import endpoints (
GET /crud/imports/{importId}/status,GET /crud/imports/{importId}/errors) - Artisan commands:
crud:install,crud:generate,crud:doctor, andcrud:cleanup-chunks
Step 2: Run the Guided Installer
Minimal Install (Config & Assets Only)
php artisan crud:installcrud:install publishes config/crud.php and frontend assets (resources/js/components/crud/, resources/js/lib/crud-theme.ts, resources/js/hooks/use-nav-items.ts), inspects package.json and resources/js/components/ui/, and prints exact commands for any missing npm packages or shadcn/ui components.
Turnkey New-Project Bootstrap (--starter)
Starting from a fresh Laravel React Starter Kit (laravel new my-app --react)? Pass --starter to interactively pick your role system (users.role column, spatie/laravel-permission, or none) and starter CRUD resources (Users and/or Posts showcase), automatically wire HandleInertiaRequests, AppLayout, app.tsx, AppSidebar, and routes/console.php, and optionally auto-install missing npm/shadcn/Spatie packages:
php artisan crud:install --starterphp artisan crud:install --starter \
--roles=column \
--examples=users \
--wire-app \
--install-deps \
--ai \
--no-interactionphp artisan crud:install --starter \
--roles=spatie \
--examples=users,posts \
--wire-app \
--install-deps \
--ai \
--no-interactionThen migrate & seed the default admin user (admin@example.com / password):
php artisan migrate
php artisan db:seed --class=CrudAdminSeederWhat --starter Scaffolds (Based on Your Choices)
- Role system (
--roles=):column—add_role_to_users_tablemigration (default('viewer')), adds'role'toUser::$fillable, and createsCrudAdminSeeder(super_admin+viewer).spatie— AddsHasRolestrait toApp\Models\User, creates a Spatie-awareCrudAdminSeeder(Role::firstOrCreate+syncRoles), and installs/publishesspatie/laravel-permissionwhen--install-depsis enabled.none— Leaves your existing auth/role setup untouched.
- Starter CRUD resources (
--examples=):users—UserController(column or Spatie-aware),UserPolicy(with self-delete guard),Dashboard/Users/{Index,Form,Show}.tsx, KPI stats, role filter, route registration, andconfig/crud.phppermissions.posts— Full v2 showcase (Postmodel + migration,PostController,PostPolicy,Dashboard/Posts/{Index,Form,Show}.tsx) featuringimageauto-upload,slug,rich-text,tags, 2-columnform_sections,visible_when,SoftDeletes, inlinetoggle/status, declarativecustom_actions, KPIstats, and built-in CSVimport.
- Host app wiring (
--wire-app): Idempotently wiresHandleInertiaRequests.php(flash+NavBuilder),app-layout.tsx(meta.breadcrumbs+sonnertoasts),app.tsx(<Toaster />+applyCustomTheme()),app-sidebar.tsx(useNavGroups()), androutes/console.php(crud:cleanup-chunkshourly schedule).
Or publish assets individually:
php artisan vendor:publish --tag=crud-config
php artisan vendor:publish --tag=crud-assetsStep 3: Scaffold & Verify
php artisan crud:generate
php artisan crud:doctorRegister your resource route in routes/web.php:
use App\Http\Controllers\Dashboard\ProductController;
Route::middleware(['auth', 'verified'])->prefix('dashboard')->group(function () {
Route::crudResource('products', ProductController::class);
});What Route::crudResource() Registers
| Method | URI | Controller Action | Route Name |
|---|---|---|---|
GET | {uri}/export | export | {name}.export |
POST | {uri}/import | import | {name}.import |
GET | {uri}/import-sample | importSample | {name}.import-sample |
POST | {uri}/bulk-destroy | bulkDestroy | {name}.bulk-destroy |
POST | {uri}/bulk-restore | bulkRestore | {name}.bulk-restore |
POST | {uri}/bulk-force-destroy | bulkForceDestroy | {name}.bulk-force-destroy |
POST | {uri}/action/{action} | handleAction | {name}.action |
POST | {uri}/{id}/restore | restore | {name}.restore |
DELETE | {uri}/{id}/force | forceDestroy | {name}.force-destroy |
| Standard | Route::resource(...) | index, create, store, show, edit, update, destroy | {name}.* |