tienhm7/laravel-hmvc-generator

这个包是为了管理使用HMVC架构模式的大型模块而创建的

v1.0.0 2022-07-06 03:02 UTC

This package is auto-updated.

Last update: 2024-09-06 07:48:18 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version composer.lock License

HMVC_Generator

Laravel包,用于使用模块[HMVC]创建和管理大型Laravel应用

文件夹结构

  • 模块
    • 用户
      • Config/
      • Database/
        • Migrations/
      • Http/
        • Controllers/
          • UserController.php
        • Middleware/
          • UserMiddleware.php
        • Requests/
          • UserRequest.php
      • Models/
        • User.php
      • Providers/
        • UserServiceProvider.php
      • Lang/
        • en/
        • vi/
      • Views/
        • index.blade.php
      • Routes/
        • web.php "所有路由在 "users" 前缀下"
        • api.php "所有路由在 "api/users" 前缀下"

Artisan命令

  • 要创建新的模块,您可以简单地运行
php artisan module:make <module_name>
  • 为指定模块创建新的控制器
php artisan module:make-controller <controller_name> --module=<module_name>
  • 为指定模块创建新的模型
php artisan module:make-model <model_name> --module=<module_name>
  • 为指定模块创建新的中间件
php artisan module:make-middleware <middleware_name> --module=<module_name>
  • 为指定模块创建新的请求
php artisan module:make-request <request_name> --module=<module_name>
  • 为指定模块创建新的迁移
php artisan module:make-migration <migration_name> --module=<module_name> --table=<table_name>

// Example:
php artisan module:make-migration create_posts_table --module=Post

路由

api.php => 这些路由由 ServiceProvider 在一个组中加载,该组分配了 "api" 中间件组和 "api/<module_name>" 前缀

web.php => 这些路由由 ServiceProvider 在一个组中加载,该组包含 "web" 中间件组和 "<module_name>" 前缀。

视图

调用视图:view('<module_name>::view_file_name')

您需要将模块服务提供者添加到config/app.php文件中的提供者列表中,并运行

composer dump-autoload