安裝依賴php
cd /var/www/html/blog composer require caffeinated/modules
編輯配置文件config/app.php,註冊服務器提供者和門面html
# 在 providers 配置項中添加註冊服務提供者web
'providers' => [bash
......服務器
Caffeinated\Modules\ModulesServiceProvider::class,app
.....composer
]ide
# 在 alias 配置項中添加註冊門面ui
'aliases'=>[spa
......
'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]:
> BasePlease enter the slug for the module: [base]:
> basePlease enter the module version: [1.0]:
> 1.0Please enter the description of the module: [This is the description for the Erp module.]:
> baseYou have provided the following manifest information:
Name: Base
Slug: base
Version: 1.0
Description: base
Basename (auto-generated): Base
Namespace (auto-generated): App\Modules\BaseIf the provided information is correct, type "yes" to generate. (yes/no) [no]:
> yesThanks! 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'); });