dhavalrajput/code-generator
Composer 安装命令:
composer require dhavalrajput/code-generator
包简介
A Laravel package with a web interface to easily create full CRUD APIs — like models, controllers, migrations, services, traits, notifications, policies, and more. Built using Laravel and Livewire.
README 文档
README
A developer-friendly Laravel package to generate models, migrations, controllers, requests, resources, factories, policies, observers, services, notifications, and traits using a modern Livewire-powered UI.
This package is designed to accelerate API development in Laravel by providing a visual interface for defining models, fields, relationships, and scaffolding complete REST endpoints.
🚀 Features
- REST API Generator: Instantly scaffold Models, Controllers, Migrations, Services, Resources, Requests, and more.
- Livewire UI: Interactive, dynamic interface for rapid development.
- Trait Support: Easily add reusable traits to your models via the UI.
- Validation & Error Handling: Smart file handling with overwrite protection.
- Highly Configurable: Customize paths, namespaces, route prefixes, and stub templates.
- Smart File Placement: Files are created in Laravel-standard folders.
- Log Viewer: View package logs directly from the UI for troubleshooting and transparency.
🧩 Requirements
- Laravel 12+
- PHP 8.2+
- Livewire 3
- spatie/laravel-query-builder
📦 Installation
-
Install via Composer:
composer require dhavalrajput/code-generator
-
Publish the configuration and migrations:
php artisan vendor:publish --tag=code-generator-config php artisan vendor:publish --tag=code-generator-migrations
-
(Optional) Customize configuration:
Edit
config/code-generator.phpto set route paths, folder locations, and stub templates as needed.
🖥️ Usage
📽️ Demo
-
Access the UI
Visit:
http://yourdomain.com/code-generator -
Define your model, fields, and relationships
- Use the UI to add fields (columns), set data types, validation, and foreign keys.
- Add Eloquent relationships visually (hasOne, hasMany, belongsToMany, etc.).
- Select which files to generate (model, migration, controller, etc.).
- Optionally, select other features like traits, observers, and notifications.
-
Generate Files
- Click "Generate" to scaffold all selected files in your Laravel app.
📜 Logs
-
The package provides a log viewer in the UI to help you review generation activity and errors.
-
To clear the logs, run the following Artisan command:
php artisan code-generator:clear-logs
⚙️ Configuration
The main configuration file is published at config/code-generator.php.
You can customize:
- Route path and prefix
- Folder paths for generated files
- Stub templates for each file type
🧑💻 Contributing
Pull requests and issues are welcome!
- Fork the repo
- Create a new branch:
git checkout -b feature/my-feature - Commit your changes and push
- Open a Pull Request
📄 License
The MIT License (MIT).
Happy coding! 🚀
dhavalrajput/code-generator 适用场景与选型建议
dhavalrajput/code-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dhavalrajput/code-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dhavalrajput/code-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-02