安装 thinkphp6
Administrator@ck MINGW64 /d/web $ composer create-project topthink/think=6.0.0 www.tp6.test
安装多应用模式扩展
$ cd www.tp6.test/ $ composer require topthink/think-multi-app $ php think build admin $ php think build api
删除 app 下默认的 controller 目录
1. app\api\controller\order 目录下 新建 Order.php
<?php declare (strict_types = 1); namespace app\api\controller\order; class Order { public function index() { return 'order - Order'; } }
2. app\api\controller\order 目录下 新建 DouyinOrder.php
<?php declare (strict_types = 1); namespace app\api\controller\order; class DouyinOrder { public function index() { return 'Order - DouyinOrder'; } }
3. api\controller\myOrder 目录下 新建 Order.php
<?php declare (strict_types = 1); namespace app\api\controller\myOrder; class Order { public function index() { return 'myOrder - Order'; } }
启动服务
Administrator@ck MINGW64 /d/web/www.tp6.test $ php think run ThinkPHP Development server is started On <http://0.0.0.0:8000/> You can exit with `CTRL-C` Document root is: D:\web\www.tp6.test\public
访问浏览器地址:
http://localhost:8000/api/order.Order/index输出:order - Order
http://localhost:8000/api/order.douyin_order/index 输出:Order - DouyinOrder
http://localhost:8000/api/myOrder.order/index输出:myOrder - Order
附:
本文为崔凯原创文章,转载无需和我联系,但请注明来自冷暖自知一抹茶ckhttp://www.cksite.cn