How to Resolve the ThinkPHP Multi‑App “Index Class Not Found” Error

This guide explains why the ThinkPHP controller Index class may not be found in a multi‑app setup, lists common causes, and provides three step‑by‑step solutions—including installing the think‑multi‑app extension, adjusting configuration files, and using full‑path URLs—along with the necessary code changes.

php Courses
php Courses
php Courses
How to Resolve the ThinkPHP Multi‑App “Index Class Not Found” Error

The article addresses the common ThinkPHP error where the controller Index class cannot be found when using the multi‑app feature, which typically occurs due to missing configuration, incorrect namespaces, or an uninstalled multi‑app extension.

Typical reasons include: (1) the multi‑app mode is not configured, (2) the controller namespace is wrong, (3) the entry file does not specify the correct user request, and (4) the required think‑multi‑app extension is not installed.

Solution 1: Install the extension via Composer with composer require topthink/think-multi-app, enable multi‑app in config/app.php by setting 'auto_multi_app' => true, verify the controller namespace, and modify the entry file to run the desired application, e.g., $response = $http->name('admin')->run();. The entry file should look like:

<?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 <[email protected]>
// +----------------------------------------------------------------------

// [ Application entry file ]
namespace think;

// Load Composer autoloader
require __DIR__ . '/../vendor/autoload.php';

// Create HTTP application and get request object
$http = (new App())->http;

// Run the request for the "admin" application
$response = $http->name('admin')->run();

// Send response and end
$response->send();
$http->end($response);

Solution 2: Keep index.php unchanged, but modify app.php to enable multi‑app and adjust the request handling. Example entry file for a single‑app mode:

<?php
// ... (same header as above)
namespace think;
require __DIR__ . '/../vendor/autoload.php';
$http = (new App())->http;
$response = $http->run(); // or $http->name('admin')->run(); if needed
$response->send();
$http->end($response);

Solution 3: Access the controller using the full path that includes the entry file, e.g.,

http://yourdomain.com/index.php/app_name/controller_name/method_name

.

After applying any of the above fixes, reload the page in a browser to verify that the application loads correctly.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendConfigurationError HandlingThinkPHPmulti-app
php Courses
Written by

php Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.