campelo/laravel-make-full
Composer 安装命令:
composer require campelo/laravel-make-full
包简介
Generate complete CRUD structure: Model, Controller, Service, Repository, Resource, Requests, Policy, Migration, Factory, Seeder - all from a single command
README 文档
README
Generate complete CRUD structure from a single command: Model, Controller, Service, Repository, Resource, Requests, Policy, Migration, Factory, Seeder.
Features
- Single Command - Generate all files at once with
php artisan make:full - Field Definition - Define fields inline and auto-generate validations, migrations, factories
- Smart Validation - Generates proper validation rules based on field types
- Search Built-in - Service/Repository includes search with pagination
- Customizable - Publish stubs to customize generated code
Installation
composer require campelo/laravel-make-full --dev
Publish config (optional):
php artisan vendor:publish --tag=make-full-config
Quick Start
# Basic usage php artisan make:full Post # With fields php artisan make:full Post --fields="title:string,content:text,published:boolean:default(false)" # Full example php artisan make:full BlogPost --fields="title:string,slug:string:unique,content:text:nullable,user_id:foreignId,published_at:datetime:nullable" --soft-deletes
Generated Files
| File | Path | Description |
|---|---|---|
| Model | app/Models/Post.php |
Eloquent model with fillable, casts, relations |
| Controller | app/Http/Controllers/PostController.php |
API controller with CRUD methods |
| Service | app/Services/PostService.php |
Business logic with search/pagination |
| Repository | app/Repositories/PostRepository.php |
Data access layer |
| Resource | app/Http/Resources/PostResource.php |
API resource transformer |
| StoreRequest | app/Http/Requests/StorePostRequest.php |
Validation for create |
| UpdateRequest | app/Http/Requests/UpdatePostRequest.php |
Validation for update |
| Policy | app/Policies/PostPolicy.php |
Authorization policy |
| Migration | database/migrations/xxx_create_posts_table.php |
Database migration |
| Factory | database/factories/PostFactory.php |
Model factory with faker |
| Seeder | database/seeders/PostSeeder.php |
Database seeder |
| Routes | routes/api.php |
API resource routes (appended) |
Field Definition Syntax
field_name:type:modifier1:modifier2:...
Supported Types
| Type | Migration | Validation | Faker |
|---|---|---|---|
string |
string() |
string|max:255 |
word() |
text |
text() |
string |
paragraph() |
integer |
integer() |
integer |
numberBetween() |
boolean |
boolean() |
boolean |
boolean() |
date |
date() |
date |
date() |
datetime |
dateTime() |
date |
dateTime() |
decimal |
decimal() |
numeric |
randomFloat() |
json |
json() |
array |
[] |
foreignId |
foreignId() |
integer|exists:table,id |
numberBetween() |
Modifiers
| Modifier | Effect |
|---|---|
nullable |
Field is optional |
unique |
Adds unique constraint + validation |
index |
Adds database index |
default(value) |
Sets default value |
Smart Field Detection
Field names automatically get appropriate faker methods:
*email*→safeEmail()*name*→name()*phone*→phoneNumber()*price*,*amount*→randomFloat(2, 10, 1000)*_id→numberBetween(1, 10)*title*→sentence(3)*description*,*content*→paragraph()
Examples
Blog Post
php artisan make:full Post --fields="title:string,slug:string:unique,excerpt:text:nullable,content:text,user_id:foreignId,published_at:datetime:nullable,views:integer:default(0)" --soft-deletes
Product
php artisan make:full Product --fields="name:string,sku:string:unique,description:text:nullable,price:decimal,stock:integer:default(0),category_id:foreignId,active:boolean:default(true)"
User Profile
php artisan make:full UserProfile --fields="user_id:foreignId:unique,bio:text:nullable,avatar:string:nullable,phone:string:nullable,birth_date:date:nullable"
Generated Code Examples
Service with Search
public function search(array $params = []): LengthAwarePaginator { $query = Post::query(); // Search filter if (!empty($params['search'])) { $search = $params['search']; $query->where(function ($q) use ($search) { $q->where('title', 'like', "%{$search}%"); $q->orWhere('content', 'like', "%{$search}%"); }); } // Sorting $sortField = $params['sort'] ?? 'created_at'; $sortOrder = $params['order'] ?? 'desc'; $query->orderBy($sortField, $sortOrder); // Pagination $limit = $params['limit'] ?? 15; return $query->paginate($limit); }
Controller
public function index(Request $request): AnonymousResourceCollection { $result = $this->service->search($request->all()); return PostResource::collection($result); }
Update Request with Unique Validation
public function rules(): array { return [ 'title' => 'sometimes|required|string|max:255', 'slug' => [ 'sometimes', 'required', 'string|max:255', Rule::unique('posts', 'slug')->ignore($this->post?->id), ], 'content' => 'sometimes|required|string', ]; }
Command Options
php artisan make:full {name}
--fields= # Field definitions
--no-model # Skip model
--no-controller # Skip controller
--no-service # Skip service
--no-repository # Skip repository
--no-resource # Skip resource
--no-requests # Skip requests
--no-policy # Skip policy
--no-migration # Skip migration
--no-factory # Skip factory
--no-seeder # Skip seeder
--no-routes # Skip routes
--soft-deletes # Add soft deletes
--uuid # Use UUID primary key
--web # Generate web controller (default is API)
--force # Overwrite existing files
Configuration
// config/make-full.php return [ // Namespaces 'namespaces' => [ 'model' => 'App\\Models', 'controller' => 'App\\Http\\Controllers', 'service' => 'App\\Services', 'repository' => 'App\\Repositories', // ... ], // Use repository pattern (Controller -> Service -> Repository) 'use_repository' => true, // Default pagination 'default_pagination' => 15, // Auto-add routes to api.php 'add_routes' => true, ];
Customizing Stubs
Publish stubs to customize generated code:
php artisan vendor:publish --tag=make-full-stubs
Stubs will be published to stubs/make-full/.
License
MIT
campelo/laravel-make-full 适用场景与选型建议
campelo/laravel-make-full 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「crud」 「laravel」 「scaffolding」 「make」 「artisan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 campelo/laravel-make-full 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 campelo/laravel-make-full 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 campelo/laravel-make-full 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Gii Generator for double model generation
A PSR-7 compatible library for making CRUD API endpoints
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
Collection of tools to use the full power of the Enyalius framework
Laravel Admin CRUD Generator
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-13