Home > PHP Framework > Laravel > Teach you to use the Laravel-Modules extension package to develop Laravel applications through modularization

Teach you to use the Laravel-Modules extension package to develop Laravel applications through modularization

藏色散人
Release: 2020-09-30 14:10:18
forward
3809 people have browsed it

下面由Laravel教程栏目给大家介绍使用 Laravel-Modules 扩展包通过模块化开发 Laravel 应用,希望对需要的朋友有所帮助!

Teach you to use the Laravel-Modules extension package to develop Laravel applications through modularization

  1. 首先在 Laravel 项目根目录下使用 Composer 安装该扩展包:
	composer require nwidart/laravel-modules
Copy after login
  1. 如不需要发布配置文件可以不用运行这条命令。该扩展包会自动注册服务提供者和别名。此外,你可以通过运行如下命令来发布配置文件:
	php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
Copy after login
  1. 执行命令,创建一个modules并新建Blog模块。也可以同时创建多个模块,如Blog、User模块 :
	php artisan module:make Blog
Copy after login
	php artisan module:make Blog User
Copy after login
  1. 让模块目录中定义的类可以自动加载,可以这样配置 composer.json:
	{
		  "autoload": {
			    "psr-4": {
			      "App\\": "app/",
			      "Modules\\": "Modules/"
			    }
		  }
	}
Copy after login
  1. 配置完成后不要忘记运行 composer dump-autoload 命令让修改生效

The above is the detailed content of Teach you to use the Laravel-Modules extension package to develop Laravel applications through modularization. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template