mosweed/laravel-auto-crud
Composer 安装命令:
composer require mosweed/laravel-auto-crud
包简介
Complete CRUD scaffolding generator for Laravel 12 with API, Blade views, Livewire components, automatic routing, custom layouts, and more
关键字:
README 文档
README
Laravel Auto CRUD
Generate complete CRUD scaffolding in seconds
Installation • Quick Start • Features • Documentation
⚡ Features
| Feature | Description |
|---|---|
| 🏗️ Complete CRUD | Models, Controllers, Views, Routes in one command |
| 🌐 API & Web | Generate API and Web controllers simultaneously |
| 🎨 Modern Views | Tailwind v4 & Bootstrap 5 with dark mode |
| ⚡ Livewire | Real-time table and form components |
| 🛣️ Auto Routing | Routes automatically added to your files |
| 🏠 App Layout | Ready-to-use layout with navigation |
| 🎯 Tailwind v4 | Auto-detects and configures CSS variables |
| 🗑️ Soft Deletes | Full restore/force-delete support |
| 🔍 Filter & Sort | Built-in query traits |
| 🧪 Tests | Automatic Pest/PHPUnit generation |
| 📋 JSON Config | Batch generate multiple CRUDs |
| ↩️ Rollback | Auto cleanup on errors |
📋 Requirements
- PHP 8.2+
- Laravel 11.x or 12.x
📦 Installation
composer require mosweed/laravel-auto-crud
Publish Layout & Welcome Page
php artisan crud:layout --welcome
Publish Configuration (Optional)
php artisan vendor:publish --tag=auto-crud-config
🚀 Quick Start
# 1. Publish layout and welcome page php artisan crud:layout --welcome # 2. Generate a complete CRUD php artisan make:crud Product \ --fields="name:string,price:decimal,description:text:nullable" \ --belongsTo=Category \ --all \ --add-to-nav # 3. Run migrations php artisan migrate # 4. Build assets npm run build
Your CRUD is ready at /products ✨
💻 Usage
Basic Command
php artisan make:crud Post
This generates:
- ✅ Model with Filterable and Sortable traits
- ✅ Web Controller
- ✅ API Controller
- ✅ Form Requests (Store & Update)
- ✅ Policy
- ✅ Blade Views (index, create, edit, show)
- ✅ Routes in
web.phpandapi.php
Command Options
| Option | Description |
|---|---|
--type=api|web|both |
Output type (default: both) |
--css=tailwind|bootstrap |
CSS framework (default: tailwind) |
--all |
Generate migration, factory, seeder, and tests |
--force |
Overwrite existing files |
--soft-deletes |
Add soft delete support |
--livewire |
Generate Livewire components |
--tests |
Generate feature and unit tests |
--fields=... |
Define fields inline |
--belongsTo=Model |
Add belongsTo relationship |
--hasMany=Model |
Add hasMany relationship |
--belongsToMany=Model |
Add belongsToMany relationship |
--json=path |
Generate from JSON configuration |
--add-to-nav |
Add to navigation menu |
Defining Fields
php artisan make:crud Post --fields="title:string,body:text,is_published:boolean"
Supported Types
| Type | Database Column |
|---|---|
string |
VARCHAR |
text |
TEXT |
integer |
INTEGER |
boolean |
BOOLEAN |
date |
DATE |
datetime |
DATETIME |
decimal |
DECIMAL |
json |
JSON |
foreignId |
BIGINT UNSIGNED |
Modifiers
--fields="title:string:255,slug:string:unique,body:text:nullable"
nullable- Field can be nullunique- Add unique constraint255- String length
Relationships
# BelongsTo php artisan make:crud Post --belongsTo=User --belongsTo=Category # HasMany php artisan make:crud User --hasMany=Post # BelongsToMany php artisan make:crud Post --belongsToMany=Tag
JSON Configuration
Create a crud.json file:
{
"models": [
{
"name": "Product",
"fields": [
{"name": "name", "type": "string"},
{"name": "price", "type": "decimal"}
],
"relationships": [
{"type": "belongsTo", "model": "Category"}
]
}
],
"options": {
"all": true,
"softDeletes": true
}
}
Run:
php artisan make:crud --json=crud.json
🏠 Layout Command
php artisan crud:layout
| Option | Description |
|---|---|
--css=bootstrap |
Use Bootstrap instead of Tailwind |
--force |
Overwrite existing layout |
--welcome |
Also publish welcome/dashboard page |
--models=Product |
Pre-populate navigation |
Welcome Page
# Layout + welcome page together php artisan crud:layout --welcome # With Bootstrap php artisan crud:layout --css=bootstrap --welcome
🔍 Filtering & Sorting
The generated models include Filterable and Sortable traits:
// Filter GET /products?status=active GET /products?price_from=10&price_to=100 GET /products?search=keyword // Sort GET /products?sort=name&direction=asc // Soft Deletes GET /products?trashed=1
🎨 Tailwind v4 Colors
Laravel 12 uses Tailwind v4 by default. Edit resources/css/app.css:
@theme { /* Primary - Change to green */ --color-primary-500: #22c55e; --color-primary-600: #16a34a; --color-primary-700: #15803d; /* Secondary */ --color-secondary-500: #6366f1; --color-secondary-600: #4f46e5; }
📁 Generated Files
app/
├── Http/Controllers/
│ ├── ProductController.php
│ └── Api/ProductController.php
├── Http/Requests/Product/
│ ├── StoreProductRequest.php
│ └── UpdateProductRequest.php
├── Models/Product.php
└── Policies/ProductPolicy.php
database/
├── factories/ProductFactory.php
├── migrations/xxxx_create_products_table.php
└── seeders/ProductSeeder.php
resources/views/
├── components/app-layout.blade.php
├── welcome.blade.php
└── products/
├── index.blade.php
├── create.blade.php
├── edit.blade.php
└── show.blade.php
📖 Documentation
For complete documentation, see DOCUMENTATION.md.
🧪 Testing
composer test
📝 Changelog
See CHANGELOG.md for recent changes.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
🔒 Security
If you discover any security-related issues, please open an issue on GitHub.
👨💻 Credits
📄 License
The MIT License (MIT). See LICENSE for more information.
Made with ⚡ by Mosweed
mosweed/laravel-auto-crud 适用场景与选型建议
mosweed/laravel-auto-crud 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「admin」 「generator」 「api」 「bootstrap」 「crud」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mosweed/laravel-auto-crud 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mosweed/laravel-auto-crud 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mosweed/laravel-auto-crud 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
2lenet/EasyAdminPlusBundle
Analysis module for finding problematical shop data.
A PSR-7 compatible library for making CRUD API endpoints
Phalcon Model Generator
Auto-generate dummy data with realistic relationships per Model-like config classes
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-01