Skip to content

Installation & Setup ​

Get up and running with nagibmahfuj/laravel-inertia-crud v2 in minutes.

Requirements ​

DependencySupported Versions
PHP^8.2
Laravel11.x, 12.x, or 13.x
Inertia.js^1.0, ^2.0, or ^3.0
React18+ or 19+
Node.js18+

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 ​

bash
composer require nagibmahfuj/laravel-inertia-crud:^2.0

Fresh 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, and crud:cleanup-chunks

Step 2: Run the Guided Installer ​

Minimal Install (Config & Assets Only) ​

bash
php artisan crud:install

crud: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:

bash
php artisan crud:install --starter
bash
php artisan crud:install --starter \
  --roles=column \
  --examples=users \
  --wire-app \
  --install-deps \
  --ai \
  --no-interaction
bash
php artisan crud:install --starter \
  --roles=spatie \
  --examples=users,posts \
  --wire-app \
  --install-deps \
  --ai \
  --no-interaction

Then migrate & seed the default admin user (admin@example.com / password):

bash
php artisan migrate
php artisan db:seed --class=CrudAdminSeeder

What --starter Scaffolds (Based on Your Choices) ​

  • Role system (--roles=):
    • column — add_role_to_users_table migration (default('viewer')), adds 'role' to User::$fillable, and creates CrudAdminSeeder (super_admin + viewer).
    • spatie — Adds HasRoles trait to App\Models\User, creates a Spatie-aware CrudAdminSeeder (Role::firstOrCreate + syncRoles), and installs/publishes spatie/laravel-permission when --install-deps is 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, and config/crud.php permissions.
    • posts — Full v2 showcase (Post model + migration, PostController, PostPolicy, Dashboard/Posts/{Index,Form,Show}.tsx) featuring image auto-upload, slug, rich-text, tags, 2-column form_sections, visible_when, SoftDeletes, inline toggle/status, declarative custom_actions, KPI stats, and built-in CSV import.
  • Host app wiring (--wire-app): Idempotently wires HandleInertiaRequests.php (flash + NavBuilder), app-layout.tsx (meta.breadcrumbs + sonner toasts), app.tsx (<Toaster /> + applyCustomTheme()), app-sidebar.tsx (useNavGroups()), and routes/console.php (crud:cleanup-chunks hourly schedule).

Or publish assets individually:

bash
php artisan vendor:publish --tag=crud-config
php artisan vendor:publish --tag=crud-assets

Step 3: Scaffold & Verify ​

bash
php artisan crud:generate
php artisan crud:doctor

Register your resource route in routes/web.php:

php
use App\Http\Controllers\Dashboard\ProductController;

Route::middleware(['auth', 'verified'])->prefix('dashboard')->group(function () {
    Route::crudResource('products', ProductController::class);
});

What Route::crudResource() Registers ​

MethodURIController ActionRoute Name
GET{uri}/exportexport{name}.export
POST{uri}/importimport{name}.import
GET{uri}/import-sampleimportSample{name}.import-sample
POST{uri}/bulk-destroybulkDestroy{name}.bulk-destroy
POST{uri}/bulk-restorebulkRestore{name}.bulk-restore
POST{uri}/bulk-force-destroybulkForceDestroy{name}.bulk-force-destroy
POST{uri}/action/{action}handleAction{name}.action
POST{uri}/{id}/restorerestore{name}.restore
DELETE{uri}/{id}/forceforceDestroy{name}.force-destroy
StandardRoute::resource(...)index, create, store, show, edit, update, destroy{name}.*

Released under the MIT License.