您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-多應用
发布时间:2022-01-29 21:45:06编辑:雪饮阅读()
現在基本上只要是個php的web框架,大多都是支持多應用部署,webman也不例外。
那麽app目錄可以佈局為這樣
[root@localhost ~]# tree /www/wwwroot/webman/webman/app
/www/wwwroot/webman/webman/app
├── admin
│ └── controller
│ └── Index.php
├── api
│ └── controller
│ └── Index.php
├── functions.php
└── shop
└── controller
└── Index.php
6 directories, 4 files
這裏需要注意的是app/下面的functions.php必須要有,即便是空的php脚本也可以。否則會報錯。
那麽這裏對應控制器的實現:
admin/controller/Index.php:
<?php
namespace app\admin\controller;
use support\Request;
class Index
{
public function index(Request $request)
{
return response('this is admin index');
}
public function view(Request $request)
{
return view('index/view', ['name' => 'webman']);
}
public function json(Request $request)
{
return json(['code' => 0, 'msg' => 'ok']);
}
}
shop/controller/Index.php:
<?php
namespace app\shop\controller;
use support\Request;
class Index
{
public function index(Request $request)
{
return response('this is shop index');
}
public function view(Request $request)
{
return view('index/view', ['name' => 'webman']);
}
public function json(Request $request)
{
return json(['code' => 0, 'msg' => 'ok']);
}
}
api/controller/Index.php:
<?php
namespace app\api\controller;
use support\Request;
class Index
{
public function index(Request $request)
{
return response('this is api 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/shop/Index/index --dump
this is shop index
[root@localhost ~]# elinks http://127.0.0.1:8787/admin/Index/index --dump
this is admin index
[root@localhost ~]# elinks http://127.0.0.1:8787/api/Index/index --dump
this is api index
关键字词:webman,多應用
上一篇:webman-日志-通道
下一篇:webman-多應用-第二彈
相关文章
- webman-日志-通道
- webman-日志-提供的方法
- webman-日志-使用
- webman-session管理-配置文件-更換session驅動為redis
- webman-session管理-配置文件-redis集群搭建(單宿主機
- webman-session管理-配置文件-更換session驅動為redis
- webman-session管理-助手函数session()-給session賦值
- webman-session管理-助手函数session()-獲取某個值
- webman-session管理-助手函数session()-session實例獲
- webman-session管理-判断对应session数据是否存在