定制 arwp/mvc 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

arwp/mvc

最新稳定版本:v1.2.0

Composer 安装命令:

composer require arwp/mvc

包简介

For building Model-View-Controller (MVC) pattern in laravel

README 文档

README

MVC Generator is a powerful package designed to streamline the creation of new modules with full CRUD functionality and generate corresponding views. This tool is an invaluable asset for accelerating your Laravel projects.

Crafted specifically for arwp/main-master, its code structure is optimized for seamless integration.

Made with ❤️ by [ARWP](https://github.com/arwahyu01)

Requirements

Features

  • Module Generation:
    Use the command php artisan make:mvc [model name] to generate a new module that includes:

    • Controller: Integrated with complete CRUD functionality.
    • Model: Configured with fillable fields and defined relationships.
    • Migration: Automatically creates the required database tables and relationships.
    • Views: Pre-built views supporting CRUD operations.
    • Route: A dedicated route for module operations.
  • Module Deletion:

    • Run php artisan delete:mvc [name] to delete MVC files one by one (with confirmation prompts).
    • Run php artisan delete:mvc [name] --all to remove all related files and database tables.

Installation

Install the package via Composer:

composer require arwp/mvc

Creating a New Module

To create a new module, execute:

php artisan make:mvc [model name]

Examples:

  • Standard Module Creation:

    php artisan make:mvc User
  • Customized Component Generation:

    Generate only specific components (e.g., model and view) by using flags:

    php artisan make:mvc User mv  # 'm' for model, 'v' for view, 'c' for controller, 't' for migration, 'r' for route
  • Single Component Creation:

    For example, to generate only views:

    php artisan make:mvc User view

Deleting a Module

To remove a module along with its associated files and database tables, run:

php artisan delete:mvc [model name]

Setup and Configuration

  1. Register the Service Provider:
    Add the service provider in your config/app.php:

    'providers' => [
        // ...
        Arwp\Mvc\MvcServiceProvider::class,
        // ...
    ],
  2. Publish the Package Resources:
    Publish the necessary resource files by running:

    php artisan vendor:publish --provider="Arwp\Mvc\MvcServiceProvider"

    This command will publish:

    • config/mvc.php
    • routes/mvc-route.php
    • Console/Commands/createMvc.php
    • Console/Commands/deleteMvc.php
  3. Configure Routing:
    Update your RouteServiceProvider.php to include the MVC routes. For example:

    public function boot()
    {
        // ...
        Route::middleware(['web', 'auth', 'backend'])
            ->namespace('App\Http\Controllers\Backend')
            ->group(base_path('routes/mvc-route.php'));
        // ...
    }
  4. Customize Paths:
    In the published config/mvc.php file, adjust the paths to suit your project structure:

    return [
        'path_controller' => 'app/Http/Controllers/Backend', // Controller folder path
        'path_model'      => 'app/Models',                     // Model folder path
        'path_view'       => 'views/backend',                  // View folder path (e.g., views/backend or views/frontend)
        'path_route'      => 'routes/mvc-route.php',           // Route file path (default: routes/mvc-route.php)
        'route_prefix'    => '',                               // Optional route prefix (e.g., backend, admin)
    ];

    To modify the default route file, simply update the path_route setting accordingly:

    return [
        // ...
        'path_route' => 'routes/web.php', // Change this to your desired route file path
        // ...
    ];

    Lastly, ensure your designated route file (e.g., routes/web.php) contains the following marker:

    //{{route replacer}} DON'T REMOVE THIS LINE

License

MVC Generator is released under the MIT License.

MVC Generator is designed to enhance the efficiency and simplicity of your development workflow. If you find this project valuable, your support with a star ⭐️ is greatly appreciated. Thank you for your contribution and happy coding! 🚀

统计信息

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

GitHub 信息

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

其他信息

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