


Solve the problem that app\controller\Index does not exist in ThinkPHP6 controller
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:
1. Reason for the error: controller Index class was not found, reasons: (1), multiple applications are not configured
(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
<?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:
1. No need to modify the index.php 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;
// 加载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);
Copy after login2. Modify the app.php file
##Solution 3:
Full path with entry file access (eg): domain name/index.php/application name/controller name/method name
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!
<?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);


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics









