The following tutorial column will introduce to you how to solve the problem that the ThinkPHP6 controller does not exist: app\controller\Index. I hope it will be helpful to friends who need it! 1. Check the error first.
Solution 1:
(2), the namespace is incorrect
(3), the entry file runs by default The user requested no configuration
(4),
Remarks (multi-application): Need to install the multi-application mode extension think-multi-app
Command line: composer require topthink/ think-multi-app2. Solution:
(1). In config/app.php, change 'auto_multi_app' => flase, to true;
(2), check whether the namespace of the controller class is correct (3), modify the entry file
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- // [ 应用入口文件 ] namespace think; //定义引用css、js等文件使用的常量 'SITE_URL' //define('SITE_URL','http://'.$_SERVER['HTTP_HOST']); // 加载composer的psr4命名规范 require __DIR__ . '/../vendor/autoload.php'; // 执行HTTP应用并响应 创建核心类 获取执行用户所发送请求的http类 $http = (new App())->http; // 运行用户的请求 //$response = $http->run(); // 运行用户的请求 多应用(设置admin应用) $response = $http->name('admin')->run(); // 响应用户的请求 $response->send(); // 结束 $http->end($response);
in the browser. Solution two:
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- // [ 应用入口文件 ] namespace think; // 加载composer的psr4命名规范 require __DIR__ . '/../vendor/autoload.php'; // 执行HTTP应用并响应 创建核心类 获取执行用户所发送请求的http类 $http = (new App())->http; // 运行用户的请求 $response = $http->run(); // 运行用户的请求 多应用(设置admin应用) //$response = $http->name('admin')->run(); // 响应用户的请求 $response->send(); // 结束 $http->end($response);
The above is the detailed content of Solve the problem that app\controller\Index does not exist in ThinkPHP6 controller. For more information, please follow other related articles on the PHP Chinese website!