thinkphp Unable to load module solution

Source: Internet
Author: User

Front Entrance file index.php

<? PHP // Front Entrance Define (' Thinkphp_path ', '. /thinkphp/'); // location of the ground floor Define (' App_path ', './home/'); // define the project location Define true); // defining the Debug switch require_once Thinkphp_path. ' Thinkphp.php '; // echo ' Hellow ';? >

Configuration file:

1 <? PHP 2 return Array (3     // ' Config item ' = ' config value ' 4      ' Default_c_layer '       =  //  default controller layer name 5      ' Url_model ' +  1,       // URL access mode, optional parameters 0, 1, 2, 3, representing the following four modes: 6 ); 7 ?>

IndexController.class.php file under Controller:

1 <? PHP 2 namespace Home\controller; 3  Use Think\controller; 4 class extends Controller {5      Public function index () {6         Echo "Hello World"; 7     }8 }

Browser Debug Results:

This path http://localhost:8080/test/index.php is a welcome message that can be displayed in the Controller method,

Http://localhost:8080/test/index.php/index and Http://localhost:8080/test/index.php/index/index, however, have prompted the error message

:(

Unable to load module: Index error location

file:c:\wamp\www\thinkphp\library\think\dispatcher.class.php line:172

TRACE

#0 C:\wamp\www\ThinkPHP\Library\Think\Dispatcher.class.php (172): E ('??????????????? ...‘)
#1 C:\wamp\www\ThinkPHP\Library\Think\App.class.php: Think\dispatcher::d ispatch ()
#2 C:\wamp\www\ThinkPHP\Library\Think\App.class.php (184): Think\app::init ()
#3 C:\wamp\www\ThinkPHP\Library\Think\Think.class.php (): Think\app::run ()
#4 C:\wamp\www\ThinkPHP\ThinkPHP.php (+): Think\think::start ()
#5 C:\wamp\www\test\index.php (7): require_once (' C:\wamp\www\Thi ... ')
#6 {main}

Then Baidu learned that the debug mode is turned on, the controller path name to be strictly case-sensitive. Epiphany, modify the address to: Http://localhost:8080/test/index.php/Index and Http://localhost:8080/test/Index.php/index are still the same problem. The official manual can be modified to be case-insensitive: Add a word to the config file: ' url_case_insensitive ' = ' = ' = True,//default false means that the URL is case-sensitive true to indicate case-insensitive. Try it, or not! Think about it, is not the controller problem, continue to consult the manual. Know

Since 3.2 thinkphp the default controller no longer uses action, but instead uses a controller that is closer to MVC mode.

If you used the action, you can change the Controller to action.

This can be defined as:

1 namespace Home\action; 2  Use think\action; 3 class extends action{}

Then, in configuration file config.php, set:

1 ' default_c_layer ' = ' Action '

Then, change the Controller to action, or the same problem, my God!

Continue Baidu!

found that the directory structure of others and I do not seem to be the same!

Review the code carefully

1 Define (' App_path ', './home/'); // define the project location

Found 3.1 generated home project directory with no home directory

And 3.2 of the generated home project directory is one more layer home directory

Therefore we must add the Home directory on the URL address, namely: Http://localhost:8080/test/index.php/Home/Index/index (file entry [index.php]/home[default]/controller name [ index]/method name [index])

Browser paste access, finally show that seductive lovely hellow world

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.