thinkphp5 / phpstudy analysis entrance index.php file and configure the domain name and localhost visit the Web site www root directory

1.thinkphp5 entry file Profile

       Speaking entry file, we first have to know what it is, on the pair of.
       First, ThinkPHP single entrance and access to project deployment model, no matter what the function is complete, an application has a unified (but not necessarily the only) entry, thinkphp5 default entry file is located public/index.php.
       It should be said 所有应用都是从入口文件开始的, and import documents of different applications are similar.
       Throughout the application 生命周期, the 第一步执行的就是入口文件request will be initiated by the user through the inlet of the application file, typically public/index.phpa file. Of course, you can also change or add a new entry file.
The default entry file index.phpcode is as follows:

// 应用入口文件

// 定义项目路径
define('APP_PATH', __DIR__ . '/../application/');
// 加载框架引导文件
require __DIR__ . '/../thinkphp/start.php';

Here Insert Picture Description

2. Visit the website root directory www

       When we finished installing phpstudy, will thinkphp5 into the root of the site www folder, we've got to test it, we have not successfully pair of thinkphp5 in the end configuration, there are two ways we can be tested.

(1) localhost visit the Web site www root directory

In the browser address bar http://localhost/thinkphp5/public/
and it will automatically have access to the http://localhost/thinkphp5/public/index/index/index
first entrance into the server file index.php, and then enter the index module, find the index controller, which then call the index () method. Specifically see FIG.
Here Insert Picture Description

Results of the:
Here Insert Picture Description

  • Here you will certainly see A pair of curious, why can index it omitted? Because thinkphp5 application configuration file config.phpthese within the parameters have default settings, so do not enter the three index, enter one or two index universally accessible to the index () method, let's look at the config.php configuration on the subject.

Here Insert Picture Description

(2) Configuration visit the Web site domain name root directory www

 This step we have to configure the domain name need to use this powerful APP phpstudy it!

Step one: Click the site domain management

Here Insert Picture Description

Step Two: Set Name

Domain: Set yourself a random, in accordance with the www.xxxx.comformat;
website directory: D:\phpStudy\WWW\thinkphp5\public(must be a public directory under the file you thinkphp5 set at www directory, which is my own file directory);
second domain name: It is also referred to as sub domain names, access it and access the main domain name is the same effect;
Web site port: default, we do not move it;
and finally click新增,保存并生成配置文件;

Here Insert Picture Description

Step 3: Check whether the configuration domain

We can view the vhosts-confprofiles to see if the configuration is successful.

Here Insert Picture Description

Step Four: Configure hosts

The domain name just configured, configure the hosts file.

Here Insert Picture Description

Step four: the browser is running, verify that the configuration is successful

Here Insert Picture Description

Here Insert Picture DescriptionHere Insert Picture Description

OK, run through it!
Published 17 original articles · won praise 1 · views 888

Guess you like

Origin blog.csdn.net/weixin_43914604/article/details/99697287