承接 sevenspan/code-generator 相关项目开发

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

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

sevenspan/code-generator

最新稳定版本:v1.1.1

Composer 安装命令:

composer require sevenspan/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

📦 Installation

  1. Install via Composer:

    composer require sevenspan/code-generator --dev
  2. Publish the configuration and migrations:

    php artisan vendor:publish --tag=code-generator-config
    php artisan vendor:publish --tag=code-generator-migrations
  3. (Optional) Customize configuration:

    Edit config/code-generator.php to set route paths, folder locations, and stub templates as needed.

📽️ Demo

![Watch the demo]

🖥️ Usage

  1. Access the UI

    Visit:

    http://yourdomain.com/code-generator
    
  2. 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.
  3. 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: 🔹 Manually (Artisan)
    php artisan code-generator:clear-logs --days
  • option days will clear logs older than provided days.

🔹 Automatically (Laravel 12+) Add this in bootstrap/app.php:

scheduler()
    ->command('code-generator:clear-logs')
    ->daily(); // or weekly/monthly

⚙️ 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! 🚀

统计信息

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

GitHub 信息

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

其他信息

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