您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-多應用-第二彈
发布时间:2022-01-29 22:10:30编辑:雪饮阅读()
在上篇中實現了webman的多應用部署,其中shop應用,也可以直接設置為"默認訪問應用"
目錄結構將調整如:
[root@localhost ~]# tree /www/wwwroot/webman/webman/app
/www/wwwroot/webman/webman/app
├── admin
│ └── controller
│ └── Index.php
├── api
│ └── controller
│ └── Index.php
├── controller
│ └── Index.php
└── functions.php
這裏只是將shop目錄内部的文件全部提上一級到直接app目錄下面了。
那麽要修改的也就只是提到app目錄下面的這個原來的shop/controller/Index.php的命名空間路徑了並修改下index方法返回内容:
<?php
namespace app\controller;
use support\Request;
class Index
{
public function index(Request $request)
{
return response('this is index');
}
public function view(Request $request)
{
return view('index/view', ['name' => 'webman']);
}
public function json(Request $request)
{
return json(['code' => 0, 'msg' => 'ok']);
}
}
該多應用項目再次部署完畢后,再次訪問如:
[root@localhost ~]# elinks http://127.0.0.1:8787/Index/index --dump
this is index
[root@localhost ~]# elinks http://127.0.0.1:8787/api/Index/index --dump
this is api index
[root@localhost ~]# elinks http://127.0.0.1:8787/admin/Index/index --dump
this is admin index
這裏可以看到之前那個shop子應用訪問的路徑就簡單了(少輸入一個'shop'...)
关键字词:webman,多應用
上一篇:webman-多應用