承接 nabila/crud-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nabila/crud-generator

Composer 安装命令:

composer require nabila/crud-generator

包简介

A Laravel package to generate full CRUD modules with advanced features

README 文档

README

CI Packagist Version

A Laravel package that generates complete CRUD modules with optional media library, translatable fields, relationships, and API resources.

Features

  • Complete CRUD Generation: Models, Migrations, Controllers, Requests, Views, Routes
  • API Support: Generate API controllers and resources instead of web interfaces
  • Media Library: Integration with Spatie Media Library for file uploads
  • Translatable Fields: Support for Spatie Translatable package
  • Relationships: Automatic relationship generation
  • Form Validation: Automatic request validation classes
  • Bootstrap Views: Ready-to-use Bootstrap-styled views
  • Customizable: Publishable stubs and configuration

Installation

Install the package via Composer:

composer require nabila/crud-generator

The package will automatically register its service provider.

Optional Dependencies

For additional features, install these packages:

# For media library support
composer require spatie/laravel-medialibrary

# For translatable models
composer require spatie/laravel-translatable

Usage

Basic Usage

Generate a complete CRUD module:

php artisan crud:make Post --fields="title:string,content:text,published:boolean"

This generates:

  • app/Models/Post.php
  • database/migrations/create_posts_table.php
  • app/Http/Controllers/PostController.php
  • app/Http/Requests/Post/StorePostRequest.php
  • app/Http/Requests/Post/UpdatePostRequest.php
  • resources/views/posts/ (index, create, edit, show)
  • Route definitions in routes/web_generated.php

Advanced Features

With Media Library Support

php artisan crud:make Product --fields="name:string,description:text,image:file,price:integer" --with-media

Translatable Fields

php artisan crud:make Article --fields="title:string,content:text,slug:string" --translatable

With Relationships

php artisan crud:make Post --fields="title:string,content:text" --relationships="belongsTo:User,hasMany:Comment"

API Generation

php artisan crud:make Product --fields="name:string,price:integer" --api

This generates API controllers and resources instead of web views.

Complex Example

php artisan crud:make BlogPost --fields="title:string,slug:string,content:text,excerpt:text:nullable,featured_image:file,published:boolean,published_at:date:nullable" --with-media --translatable --relationships="belongsTo:User,belongsTo:Category,hasMany:Comment" --force

Available Field Types

  • string - VARCHAR field
  • text - TEXT field
  • integer - INTEGER field
  • boolean - BOOLEAN field
  • date - DATE field
  • email - VARCHAR with email validation
  • file - File upload field (works with --with-media)

Add :nullable to make fields optional:

--fields="name:string,description:text:nullable,age:integer:nullable"

Command Options

Option Description
--fields Required. Comma-separated fields with types
--with-media Include Spatie Media Library support
--translatable Make model translatable
--relationships Add relationships (belongsTo:Model,hasMany:Model)
--api Generate API routes and controller
--force Overwrite existing files

List Available Commands

php artisan crud:list

Generated Files Structure

For Web CRUD:

app/
├── Models/Post.php
└── Http/
    ├── Controllers/PostController.php
    └── Requests/Post/
        ├── StorePostRequest.php
        └── UpdatePostRequest.php

database/migrations/
└── 2024_01_01_000000_create_posts_table.php

resources/views/posts/
├── index.blade.php
├── create.blade.php
├── edit.blade.php
└── show.blade.php

routes/
└── web_generated.php

For API CRUD:

app/
├── Models/Post.php
└── Http/
    ├── Controllers/Api/PostController.php
    ├── Resources/PostResource.php
    └── Requests/Post/
        ├── StorePostRequest.php
        └── UpdatePostRequest.php

routes/
└── api_generated.php

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=nabila-crud-config

Publish the stubs for customization:

php artisan vendor:publish --tag=nabila-crud-stubs

Customization

After publishing stubs, you can customize the templates in stubs/nabila-crud/. The generator will use your custom stubs if they exist.

Available Stubs

  • model.stub - Model template
  • migration.stub - Migration template
  • controller.stub - Web controller template
  • api-controller.stub - API controller template
  • store-request.stub - Store request validation
  • update-request.stub - Update request validation
  • resource.stub - API resource template
  • views/index.blade.stub - Index view template
  • views/create.blade.stub - Create view template
  • views/edit.blade.stub - Edit view template
  • views/show.blade.stub - Show view template
  • routes.stub - Web routes template
  • api-routes.stub - API routes template

Integration

Register Generated Routes

Add to your routes/web.php:

if (file_exists(__DIR__ . '/web_generated.php')) {
    require __DIR__ . '/web_generated.php';
}

Add to your routes/api.php:

if (file_exists(__DIR__ . '/api_generated.php')) {
    require __DIR__ . '/api_generated.php';
}

Run Migrations

After generating your CRUD:

php artisan migrate

Requirements

  • PHP 8.1+
  • Laravel 10.0+, 11.x or 12.x

License

This package is open-sourced software licensed under the MIT license.

Contributing

Please see CONTRIBUTING.md for details.

Changelog

Please see CHANGELOG.md for more information on what has changed recently.

Credits

Support

If you discover any security related issues, please email nabilashabban2000@gmail.com instead of using the issue tracker.

nabila/crud-generator 适用场景与选型建议

nabila/crud-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「generator」 「package」 「crud」 「laravel」 「artisan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nabila/crud-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nabila/crud-generator 我们能提供哪些服务?
定制开发 / 二次开发

基于 nabila/crud-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-12