thinkphp6 多应用模式下,多级控制器访问

        安装 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

冷暖自知一抹茶ck


附:

        thinkphp6配置多应用项目及多域名访问路由app配置

        多级控制器

冷暖自知一抹茶ck
请先登录后发表评论
  • 最新评论
  • 总共0条评论