thinkphp Project construction and portal document concept ____php

Source: Internet
Author: User
Tags php framework
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.

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.