Download the PHP package houdunwang/laravel-module without Composer

On this page you can find all versions of the php package houdunwang/laravel-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-module

组件介绍

通过使用模块来管理大型Laravel项目,模块就像一个laravel包非常方便的进行添加或移除。

这个包已经在 HDCMS 中使用。

模块是在 nwidart.com/laravel-moduleslaravel-permission 组件基础上扩展了一些功能,所以需要先安装这两个组件。

laravel-modules 和 laravel-permission 组件的功能都可以正常使用

安装组件

composer require houdunwang/laravel-module

php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="config"

php artisan vendor:publish --provider="Houdunwang\Module\LaravelServiceProvider"

php artisan migrate

配置 composer.json 设置自动加载目录

{
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Modules\\": "Modules/"
    }
  }
}

创建模块

下面的命令是安装 Admin 模块

创建模块会同时执行以下操作:

模块配置

新建模块时系统会自动创建配置,一般情况下不需要执行以下命令生成配置文件(除组件添加新配置功能外)

文件说明

获取配置

下面是获取 Admin/config/config.php 文件中的name值,支持 . 从深度嵌套的数组中检索值。

保存配置

后台菜单

系统会根据模块配置文件 menus.php 生成后台菜单项

当 menus.php 文件不存在时,执行 php artisan hd:config Admin 系统会为模块 Admin 创建菜单。

获取菜单

获取系统可使用的所有菜单,以集合形式返回数据。可用于后台显示菜单列表。

权限管理

首先需要安装 laravel-permission 组件,安装方式在上面已经介绍。

创建权限配置

系统根据 Admin 模块配置文件 permission.php 重新生成权限,执行以下命令会创建权限配置文件。

不指定模块时生成所有模块的权限表

文件存在时不会覆盖

生成的配置文件结构如下:

name 指用于验证时的 权限标识 ,可以使用任何字符定义。如果以 控制器@方法 形式定义的,在使用中间件验证时会比较容易。

获取权限配置

根据 guard 获取权限数据,可用于后台配置设置表单。

中间件

laravel-permission 组件提供了中间件功能,但处理不够灵活并对资源控制器支持不好。所以houdunwang/laravel-module 组件提供了中间件的功能扩展,你也可以使用 laravel-permission 中间件的所有功能。

以下都是对 houdunwang/laravel-module扩展中间件的说明,laravel-permission 中间件使用请查看组件手册。

使用中间件路由需要模块 permission.php 配置文件中的权限标识为 控制器@方法形式。

配置

app/Http/Kernel.php 文件的 $routeMiddleware 段添加中间件

站长特权

配置文件 config/hd_module.php 文件中定义站长使用的角色。

在使用中间件验证时,如果不前用户所在角色为站长角色,系统不进行验证直接放行。

普通路由

系统根据控制器方法检查是否存在权限规则,然后自动进行验证。

所以必须正确设置路由配置文件,下面是对编辑文章的权限设置

下面是编辑文章的路由定义,必须保存 Modules\Admin\Http\Controllers\ArticleController@edit 规则已经在权限配置文件中定义,否则系统不验证。

上面的 permission 中间件的 admin 参数是权限 guard

资源路由

资源路由新增资源由 createstore方法完成,更新资源由 editupdate 方法完成。权限规则只需要设置 createedit 方法即可,在执行 store 动作时系统会自动使用 create 方法规则,update 动作会使用 create 方法规则,下面是用户管理的资源控制器规则设置:

资源路由中间件的使用

上面的 permission 中间件的 admin 参数是权限 guard,中间件 permission 的第二个参数 resource 表示这是一个资源路由验证。

模块方法

获取模块对象

获取当前请求使用的模块名

获取模块菜单,参数为模块标识,不传参数时获取当前模块菜单

验证权限如果用户是站长直接放行

获取模块列表,参数为不需要返回的模块,不传参数获取所有模块

获取模块路径

自动化构建

大部分业务由 Controller控制器、Request请求难、Model模型、View视图、Handle处理器构成,很多时间这些工作都是重复的,系统支持通过一行命令生成业务需要的大部功能。

生成工作是根据模型和数据表完成的,所以必须先创建模型在数据库中创建模型表。

创建模型和迁移

执行以下命令系统会为 Article 模块创建 Category模型和对应的数据迁移文件。

执行自动化构建

首先安装组件

下面是根据 Article 模块的 Category 模型生成业务框架,系统同时会创建模型表单处理器,请查看 https://github.com/houdunwang/laravel-autocreate 学习。

执行以下命令会创建下列文件

  1. 创建控制器 Http/Controllers/CategoryController
  2. 表单验证请求 Http/Request/CategoryRequest
  3. 添加路由规则 routes.php
  4. 生成模版视图

必须保存模型与数据表存在,某个文件存在时忽略这个文件继续向下执行

License

The Laravel framework is open-sourced software licensed under the MIT license.


All versions of laravel-module with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package houdunwang/laravel-module contains the following files

Loading the files please wait ....