Thinkphp Framework Basics

Source: Internet
Author: User

Thinkphp is a PHP development framework that uses an object-oriented development structure and an MVC pattern, referred to as the TP framework.

1. Framework is a collection of code, there are variables, functions, classes, constants, there are many design patterns MVC, AR database, singleton, etc., the role of the framework is to save a lot of development workload, in order to focus on the business level.

2.MVC mode:

M:model Data Model layer, responsible for data manipulation

V:view view layer, responsible for displaying the view

C:controller Controller for business logic

The user accesses the program by accessing the operation method inside the controller, the operation method can manipulate the data through the model layer, and can control the template display to display the view.

3.TP Frame URL address notation:

(1) Basic get mode:/HTTP URL/index.php?m=xx&c=xx&a=xx

(2) path mode pathinfo:http://URL/index.php/module/controller/operation method

(3) Rewrite rewrite mode://URL/module/controller/operation method

(4) Compatibility mode: HTTP//URL/index.php?s=/module/controller/method

In general, the second method of path mode access is used.

The shortcut function u ("module/Controller/Operation Method") can create the corresponding URL address according to the parameter and URL pattern, the URL mode to modify the Conf folder in the Thinkphp folder under the TP folder in the configuration file convention.php in the ' Url_model ' Values, 1 to 4 represent 4 modes respectively

    Note : If you want to modify the files in the thinkphp, it is a good idea to copy the files you want to modify into the module and modify them.

4. Framework Project Deployment

To deploy a shop project using the TP framework, for example,

(1) First, create a portal file and create a portal file under the thinkphp directory index.php

    

(2) Then, access to the Portal file system will automatically put the corresponding application directory file shop to wear out,

    

(3) Open the home folder,

    

5. Creation of controllers and operating methods

(1) Create a new controller file under the \shop\home\controller folder LoginController.class.php

    

(2) Open the file, build the controller login class inside

    

(3) If you want to customize the operation method, add a function login () to the Controller login class:

    

(4) If you want to invoke a template in the view layer in the controller:

    

However, the premise of this is to have a corresponding view template file.

5. Creation of view template files

(1) The view template file is stored in the location:

    

Initially there is no template file, if we want to access the login controller in the login method, we will first create a login controller corresponding to the template folder, the folder corresponding to the login controller:

    

This allows you to display the template file again before you access the Ligin () action method.

  

Thinkphp Framework Basics

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.