Entry File
A project (System) usually has a unified entry file, all of the project's functional operations are carried out through this portal file, and often the entry file is executed first, which is a very important concept in the thinkphp or PHP framework.
The Create entry file is described below. Project Directory Planning
Usually we have a project or a website, according to the situation can be simply divided as follows: Only a relatively simple application based on thinkphp development, such as the CMS system. Based on thinkphp development Tianjin whole Station optimization company's application and other systems integration. Other more complex situations, which are not discussed further here.
The reason for this discussion of the project directory planning above is that the resulting project folder distribution will be somewhat different when the entry file is set with different parameters, as described below. Create a portal file
The following is the most common example of a portal file, which applies to most situations, especially the 2nd and 3 scenarios in the project plan above, and is also a recommended example.
Suppose we create a project with the name MyApp, create a file index.php in the UTF-8 format under the Web root, and the contents of the file are as follows:
<?php
//Entry file
//definition project name and path
define (' app_name ', ' MyApp ');
Define (' App_path ', './myapp/');
Open Debug Mode
define (' App_debug ', true);
Load frame Entry file
require ("./thinkphp/thinkphp.php");
? >
In the portal file, the project name and path are defined, the debug mode is turned on, and the frame entry file thinkphp.php is loaded. compared to the 2.x version of the Change 3.0 version removed App::run (); Instantiate the applied code, or the program will execute two times. Version 3.0 will adjust the debug mode switch in the original configuration file into the entry file. App_path must be in/over. Create a project
After you save the portal file, create the MyApp folder in the same directory to hold the project files. To access the portal file you just created in the browser:
http://localhost/index.php
You can see that the browser appears with project build Success tips:
At this point, the application project has been created successfully, and you can begin project development based on thinkphp. If the page cannot be displayed, check the configuration of the portal file or whether the Web service and directory configuration are correct, and whether the MyApp directory has writable permissions.
Recommendation: Try to configure the virtual host locally to simulate the actual web site running environment.