khaledneam/module-generator 问题修复 & 功能扩展

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

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

khaledneam/module-generator

最新稳定版本:v1.0.1

Composer 安装命令:

composer require khaledneam/module-generator

包简介

A Laravel package to generate module structures.

README 文档

README

A Laravel package to quickly generate modular components such as Controllers, Models, Views, Repositories, and Services. This package helps in creating a modular structure in Laravel applications, making the code more organized and manageable.

Features

  • Create directories for Controllers, Models, Requests, Routes, Views, Migrations, Tests, Providers, Repositories, and Services.
  • Generate Service Providers, Controllers, Views, Routes, Repositories, and Services files with basic templates.
  • Automatically register the Service Provider in config/app.php.
  • Automatically include module routes in routes/web.php.
  • Update helpers.php file to include module_path function.

Installation

  1. Install the package via Composer:

    composer require khaledneam/module-generator dev-main --dev
  2. Ensure you also add the Modules directory in the root of your Laravel project

  3. If you do not have helpers.php in your app directory, create it as an empty file

  4. Update composer.json

{
    "autoload": {
        "psr-4": {
            "Modules\\": "Modules/"
        }
    },
    "files": [
        "app/helpers.php"
    ]
}

Then, update Composer’s autoload files:

composer dump-autoload

Usage To create a new module, use the following Artisan command:

php artisan make:module ModuleName

Example

php artisan make:module Blog

This will create a new module named Blog with the following structure:

Modules/
    Blog/
        Controllers/
        Models/
        Requests/
        Routes/
        Views/
        Migrations/
        Tests/
        Providers/
        Repositories/
        Services/

Generated Files

Service Provider: Modules/ModuleName/Providers/ModuleNameServiceProvider.php
Controller: Modules/ModuleName/Controllers/ModuleNameController.php
View: Modules/ModuleName/Views/index.blade.php
Route File: Modules/ModuleName/Routes/web.php
Repository: Modules/ModuleName/Repositories/ModuleNameRepository.php
Service: Modules/ModuleName/Services/ModuleNameService.php

Important Notes

1.Register the Service Provider:

Ensure that you add the newly created module's service provider to the providers array in config/app.php:

'providers' => [
    // Other Service Providers
    Modules\ModuleName\Providers\ModuleNameServiceProvider::class,
],

Contributing

Feel free to fork the repository and submit pull requests. Any contributions are welcome.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固