Laravel5.5 配置多模块

安装依赖

cd /var/www/html/blog
composer require caffeinated/modules

编辑配置文件config/app.php,注册服务器提供者和门面

# 在 providers 配置项中添加注册服务提供者

'providers' => [

    ......

    Caffeinated\Modules\ModulesServiceProvider::class,

    .....

]

# 在 alias 配置项中添加注册门面

'aliases'=>[

    ......

    'Module' => Caffeinated\Modules\Facades\Module::class

]

生成模块

cd /var/www/html/blog
php artisan make:module Base

root@shfumio:/var/www/html/erp# php artisan make:module Base
*-----------------------------------------------*
|                                               |
|              Copyright (c) 2016               |
|                  Shea Lewis                   |
|                                               |
|         Thanks for using Caffeinated!         |
*-----------------------------------------------*
______  ___     _________      ______
___   |/  /___________  /___  ____  /____________
__  /|_/ /_  __ \  __  /_  / / /_  /_  _ \_  ___/
_  /  / / / /_/ / /_/ / / /_/ /_  / /  __/(__  )
/_/  /_/  \____/\__,_/  \__,_/ /_/  \___//____/  

*-----------------------------------------------*
|                                               |
|          Step #1: Configure Manifest          |
|                                               |
*-----------------------------------------------*


 Please enter the name of the module: [Base]:
 > Base

 Please enter the slug for the module: [base]:
 > base

 Please enter the module version: [1.0]:
 > 1.0

 Please enter the description of the module: [This is the description for the Erp module.]:
 > base

You have provided the following manifest information:
Name:                       Base
Slug:                       base
Version:                    1.0
Description:                base
Basename (auto-generated):  Base
Namespace (auto-generated): App\Modules\Base

 If the provided information is correct, type "yes" to generate. (yes/no) [no]:
 > yes

Thanks! That's all we need.
Now relax while your module is generated.
 2/2 [============================] 100%
Module generated successfully.
 

此时,在app/Modules下有一个Base的文件夹

访问域名  xxxx.com/base

出现默认提示

"This is the Base module index page. Build something great!"

创建控制器

app/Modules/Base/Http/Controllers

IndexControllers.php

<?php

namespace App\Modules\Erp\Http\Controllers;
use App\Http\Controllers\Controller;
class IndexController extends Controller{
    public function index(){
        echo 'sss';
        return view('base::Index.index');
    }
}

 创建模板

app\Modules\Base\Resources\Views\Index\index.blade.php

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
hello world
</body>
</html>

修改F:app\Modules\Base\Routes\web.php

<?php

Route::group(['prefix' => 'base'], function () {
    Route::get('/', function () {
        dd('This is the Base module index page. Build something great!');
    });
    Route::get('/index','IndexController@index');
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值