Thinkphp Learning Project Deployment: Application Deployment approach and Module grouping deployment method

Source: Internet
Author: User
Tags php framework

/**/

thinkphp (official website: http://www.thinkphp.cn/) Currently the latest version is 3.2.2, which requires PHP version is higher than 5.3.0, because my wampserver integrated PHP version is 5.2.6, so download a low version of T hinkphp (3.1.3) to learn.

The structure of the downloaded thinkphp framework package after decompression is:

├─thinkphp. PHP Framework Portal File ├─common Framework common file ├─conf Framework configuration file ├─extend Framework Extensions directory ├─lang Core Language Pack directory ├─lib core class library directory │├─behavior core behavior Class Library │├─core core base Class library │├─d River built-in driver ││├─cache built-in cache driver ││├─db built-in database driver ││├─taglib built-in tag driver ││└─template built-in template engine driver │└─template built-in template engine └─tpl system template directory

Create the project directory app under the WEB root directory, put the framework package in the app directory, and create the portal file index.php in the app directory.

Configuring the Portal File index.php

<? PHP Define (' Think_path ', './thinkphp/'); require (Think_path. " Thinkphp.php ");

The index.php file is accessed via a URL, and the page displays:

The content page has changed in the project directory APP, except for the portal file index.php and the framework package, and the others are automatically generated:

The role of each folder is:

├─index. PHP     Project portal File ├─common project Common Files directory ├─conf project configuration directory ├─lang Project language directory ├─lib Project class library catalog │  ├─action Action class Library │  ├─behavior Behavior Library Catalog │  ├─model Model Class library catalog │  └─widget Widget Class library catalog ├─runtime Project runtime Catalog │  ├─cache Template Cache directory │  ├─data data Cache directory │  ├─logs log file directory │  └─temp temporary cache directory └─TPL project template directory

This way the entry file index.php is present within the project directory. You can also move the portal file to the outside of the app directory and modify the portal file index.php:

<? PHP Define (' Think_path ', './app/thinkphp/'); Define (' App_name ', ' APP '); Define (' App_path ', './app/'); require (Think_path. " Thinkphp.php ");

Directory structure:

How the project is deployed

The deployment of the project is divided into application deployment and module grouping deployment. application Deployment is each project corresponding to a portal file, such as the foreground entrance file corresponding to index.php, background entry file corresponding to admin.php

Front Entrance file index.php:

<? PHP
Define (' Think_path ', './thinkphp/'); Define (' App_name ', ' home '); Define (' App_path ', './home/'); require (Think_path. " Thinkphp.php ");

Background entry file admin.php:

<? PHP Define (' Think_path ', './thinkphp/'); Define (' app_name ', ' admin '); Define (' App_path ', './admin/'); require (Think_path. " Thinkphp.php ");

If a block module is used, it can be simplified as a project directory. The template file of the project is still placed under the project's TPL directory, just the external call of the resource files, including the picture JS and CSS Unified into the public directory of the Web site, Images, JS and CSS subdirectory storage, if possible, You can even place these resource files on a separate external server for remote invocation and optimization. (In fact, the system directory and the project directory can be placed under the non-Web Access directory, the site directory only need to put public directory and portal files, so as to improve the security of the site.) )

(Image source: http://www.php400.cn/275.html)

The modules are grouped in such a way as to configure App_name and App_path.

Reference: thinkphp Official tutorials, thinkphp official documents, HTTP://WWW.PHP400.CN/CATEGORY/THINKPHP%E6%A1%86%E6%9E%B6, PHP MVC development Combat

Thinkphp Learning Project Deployment: Application Deployment approach and Module grouping deployment method

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.