sndpbag/crud-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sndpbag/crud-generator

Composer 安装命令:

composer require sndpbag/crud-generator

包简介

A powerful Laravel CRUD generator package with advanced features

README 文档

README

"# CRUD Generator"

🚀 Laravel CRUD Generator

Latest Version Total Downloads License Stars

Generate complete Laravel CRUD in seconds with a single command!

FeaturesInstallationQuick StartDocumentationContributing

🎯 Why This Package?

Stop wasting time writing repetitive CRUD code! This package generates:

  • ✅ Model with relationships
  • ✅ Migration with all field types
  • ✅ Controller with complete CRUD logic
  • ✅ Form Request validation classes
  • ✅ Beautiful responsive views (Bootstrap/Tailwind)
  • ✅ Automatic route registration
  • ✅ Feature tests
  • ✅ And much more...

All in just 5 seconds!

✨ Features

🎨 Smart Generation

  • 26 Advanced Features
  • Smart field type detection
  • Enum fields with dropdowns
  • File & image uploads
  • Relationship scaffolding

🔧 Developer Friendly

  • Customizable stubs
  • Bootstrap & Tailwind support
  • API mode (JSON responses)
  • Authentication support
  • Email Notification (Mailable + Job) support

🧪 Testing Ready

  • PHPUnit test generation
  • Pest test support
  • Complete test coverage
  • TDD workflow

📦 Production Ready

  • Namespaced generation
  • Soft deletes
  • Search & sorting
  • Pagination

📦 Installation

composer require sndpbag/crud-generator

That's it! No configuration needed. Start generating CRUDs immediately.

🚀 Quick Start

Basic Example

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

Generated files in 5 seconds:

  • app/Models/Product.php
  • database/migrations/..._create_products_table.php
  • app/Http/Controllers/ProductController.php
  • app/Http/Requests/StoreProductRequest.php
  • app/Http/Requests/UpdateProductRequest.php
  • resources/views/products/*.blade.php
  • ✅ Routes in routes/web.php

Run migration and you're done:

php artisan migrate

Visit: http://localhost/products 🎉

💡 Advanced Usage

E-commerce Product CRUD

php artisan make:crud Product \
  --fields="name:string:unique,slug:string:unique,price:decimal:default(0),stock:integer,image:image:nullable,status:enum(active,inactive):default('active'),is_featured:boolean:default(0)" \
  --belongsTo=Category \
  --belongsTo=Brand \
  --softdelete \
  --auth \
  --tests

Admin Panel

php artisan make:crud Admin/Post \
  --fields="title:string:unique,content:text,featured_image:image:nullable" \
  --belongsTo=User \
  --belongsTo=Category \
  --auth

API Endpoints

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

📧 ইমেল নোটিফিকেশন সহ CRUD

আপনি যদি চান যে নতুন কোনো ডেটা তৈরি (create) হওয়ার সাথে সাথে একটি ইমেল নোটিফিকেশন পাঠানো হোক, তবে --email ফ্ল্যাগটি ব্যবহার করুন।

php artisan make:crud Order --fields="item_name:string,price:integer" --belongsTo=User --email


এটি স্বয়ংক্রিয়ভাবে তৈরি করবে:

✅ app/Mail/OrderCreatedMailable.php (ShouldQueue সহ)

✅ app/Jobs/SendOrderCreatedEmailJob.php

✅ resources/views/emails/order.blade.php (Markdown টেমপ্লেট)

✅ OrderController-এর store মেথডে জব ডিসপ্যাচ করার কোড।


---

## 🎨 Field Types

| Type | HTML | Example |
|------|------|---------|
| string | `<input type="text">` | `name:string` |
| text | `<textarea>` | `description:text` |
| integer | `<input type="number">` | `age:integer` |
| decimal | `<input type="number">` | `price:decimal` |
| boolean | `<input type="checkbox">` | `is_active:boolean` |
| date | `<input type="date">` | `birth_date:date` |
| datetime | `<input type="datetime-local">` | `published_at:datetime` |
| email | `<input type="email">` | `email:email` |
| file | `<input type="file">` | `document:file` |
| image | `<input type="file" accept="image/*">` | `photo:image` |
| enum | `<select>` | `status:enum(active,inactive)` |

---

## 🔧 Modifiers

```bash
# Nullable field
--fields="description:text:nullable"

# Unique constraint
--fields="email:email:unique"

# Default value
--fields="status:enum(active,inactive):default('active')"

# Combine modifiers
--fields="slug:string:unique:nullable"

🔗 Relationships

# BelongsTo (generates dropdown in forms)
--belongsTo=User --belongsTo=Category

# HasMany
--hasMany=Comment --hasMany=Review

🎯 Command Flags

Flag Description Example
--fields Define fields --fields="name:string,price:integer"
--belongsTo Add belongsTo relationship --belongsTo=User
--hasMany Add hasMany relationship --hasMany=Comment
--softdelete Enable soft deletes --softdelete
--auth Add auth middleware --auth
--api Generate API instead of web --api
--tests Generate PHPUnit tests --tests
--pest Generate Pest tests --pest
--email নতুন রেকর্ড তৈরি হলে ইমেল পাঠানোর জন্য Mailable ও Job তৈরি করে --email

🗑️ Rollback

Delete all generated files:

php artisan crud:delete Product

📚 Documentation

🎥 Video Tutorial

Coming soon! Subscribe to our YouTube channel.

📊 Comparison

Feature Manual Coding This Package
Time Required ~2 hours 5 seconds
Model ✋ Manual ✅ Auto
Migration ✋ Manual ✅ Auto
Controller ✋ Manual ✅ Auto
Validation ✋ Manual ✅ Auto
Views ✋ Manual ✅ Auto
Routes ✋ Manual ✅ Auto
Tests ✋ Manual ✅ Auto
File Uploads ✋ Manual ✅ Auto
Relationships ✋ Manual ✅ Auto

🌟 Real-World Examples

Blog System

php artisan make:crud Post --fields="title:string:unique,content:text,status:enum(draft,published)" --belongsTo=User --hasMany=Comment --softdelete --auth --tests

Inventory Management

php artisan make:crud Product --fields="sku:string:unique,name:string,stock:integer,price:decimal" --belongsTo=Category --belongsTo=Supplier --auth

Booking System

php artisan make:crud Appointment --fields="appointment_date:datetime,status:enum(pending,confirmed,cancelled)" --belongsTo=User --belongsTo=Service --auth

See more in EXAMPLES.md

⚙️ Configuration

Publish config file:

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

Customize in config/crud-generator.php:

return [
    'template' => 'bootstrap', // or 'tailwind'
    'storage_path' => 'public/uploads',
    'pagination' => 10,
    'alert_library' => 'sweetalert2',
];

আপনি `config/crud-generator.php` ফাইলে ডিফল্ট ভ্যালু পরিবর্তন করতে পারেন।

প্রথমে কনফিগ ফাইলটি পাবলিশ করুন:
```bash
php artisan vendor:publish --tag=crud-generator-config


📧 ইমেল নোটিফিকেশন সেটআপ (Email Notification Setup)
--email ফ্ল্যাগটি ব্যবহার করার জন্য আপনাকে দুটি জিনিস সেট করতে হবে:

১. অ্যাডমিন ইমেল সেট করুন: JobGenerator স্বয়ংক্রিয়ভাবে মডেলে email ফিল্ড খুঁজে বের করার চেষ্টা করে। যদি না পায়, তবে এটি config/crud-generator.php ফাইলে থাকা admin_email ব্যবহার করে।

আপনার .env ফাইলে অ্যাডমিন ইমেল যোগ করুন:

ADMIN_EMAIL="your_admin_email@example.com"

২. Queue Worker চালু করুন: ইমেলগুলো যেন ইউজার এক্সপেরিয়েন্স নষ্ট না করে, সেজন্য এগুলো Queue-এর মাধ্যমে পাঠানো হয় (ShouldQueue)। তাই আপনাকে অবশ্যই একটি Queue Worker চালু রাখতে হবে:

php artisan queue:work

🎨 Customize Templates

Publish stubs:

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

Edit files in stubs/crud-generator/ to customize generated code.

🧪 Testing

Run package tests:

composer test

Generate tests for your CRUD:

php artisan make:crud Product --fields="name:string" --tests
php artisan test

🤝 Contributing

We love contributions! Please read our Contributing Guide.

Contributors

📝 Changelog

See CHANGELOG.md for all changes.

🐛 Issues

Found a bug? Open an issue

💬 Discussions

Have questions? Start a discussion

⭐ Star History

Star History Chart

📄 License

The MIT License (MIT). See LICENSE for details.

💝 Support

If you find this package helpful, please consider:

  • ⭐ Starring the repository
  • 🐛 Reporting bugs
  • 💡 Suggesting features
  • 📖 Improving documentation
  • Buy me a coffee

🙏 Acknowledgments

  • Laravel Community
  • All Contributors
  • Open Source Community

Made with ❤️ for the Laravel Community

Built by sandipan kr bag

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-22