zingle-com/laravel-modules

为Laravel添加模块。

安装次数: 16,289

依赖者: 1

建议者: 0

安全性: 0

星标: 0

关注者: 3

分支: 0

公开问题: 0

类型:laravel-package

1.0.0 2020-01-31 04:16 UTC

This package is auto-updated.

Last update: 2024-08-29 04:31:32 UTC


README

Build Status Coverage Status

为您的Laravel项目添加模块化架构的简单辅助工具。

概述

模块化架构使您的应用程序更容易理解和扩展。此包旨在以最少的努力和最大的灵活性添加对模块的支持。在此包中,“模块”对应于项目中的代码模块分组。

安装

使用composer安装基础包。

$ composer install zingle-com/laravel-modules

在Illuminate提供者之后、您的项目提供者之前,将服务提供者添加到您的提供者中。

// config.php
// ...
	'providers' => [
		// ...
		Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,

        /**
         * Vendors
         */
    	// ...
    	ZingleCom\LaravelModules\ModuleServiceProvider::class,

    	// ...
    	/**
    	 * Project providers
    	 */
	],

最后,安装供应商资源

$ php artisan vendor:publish --provider="ZingleCom\LaravelModules\ModuleServiceProvider::class"

使用方法

在定义了您的模块化结构之后,要创建一个新模块,只需在对应于模块名称的基础模块目录中添加一个新的扩展Module的类。例如,如果您有一个名为Auth的模块,其基础目录为app/Modules/Auth,您将创建以下类

namespace App\Modules\Auth;

use ZingleCom\LaravelModules\Module\Module;

class AuthModule extends Module
{

}

然后,将新模块类添加到config/modules.php中的modules键下,例如

// modules.php
// ..
	"modules" => [
		App\Modules\Auth\AuthModule::class,
	],