Basic TP framework knowledge and tp framework

Source: Internet
Author: User

Basic TP framework knowledge and tp framework

TP framework versions 3, 2, and 3
3.2.3 compared with 5.0, 5.0 is more flexible, but troublesome

Function: makes the front-end, database, and logical separation more labor-intensive;

Objective: To facilitate program development, disrupt the structure, and develop tools;

A: principle and structure BCDE: Content and content usage
**************************************** *************************************
O. Principle items:

Principles of the TP framework:
1. Convention 2. Victory 3. configuration;
Controller naming rules: camper name method; ==>
Controller name + Controller;

The class name must be the same as the file name
**************************************** *************************************

######################################## ######################################
A. Directory and file-> composition structure:

1. original folder:
1. Application => (local storage, user-created class) operable: Application folder
A: Common applications => Functions and configurations
B: Home module folder => b1: MVC mode; (@ core) b2: function, configuration class;
C: files generated during Runtime running => cache and so on;

2. Public => (Local Storage) externally accessible: Function Method folder

3. ThinkPHP => (Local Storage) current storage class: TP Framework Program Composition-> core folder
A: library CORE class: Common Think => for example, the method of the parent class controller is

I. @ non-original folder: @ (user-created )@@@
Self-built: Application folder => self-built module (Home) => self-built controller (method: Class)

Ii. Original file:
1. index. php => entry file (feature set and start file) => access the start File
File Content:
A: PHP detection,
B: debugging mode: for development,
C: Define the application directory (or custom)
D: Introduce the thinkphp entry file;

######################################## ######################################
B. module configuration items:

Config configuration in the module (home) folder ==>
Configurations required by your program;
Main configuration =>
1. application configuration
2. default settings
3. Database settings... during development: Disable SQL logs
4. template settings
5. URL setting: For generation rather than access

Configuration not shown =>
'Show _ PAGE_TRACE => true' enables trace information.
######################################## ######################################

C. MVC and access: (content in the module)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
Core of the TP framework (in the module) => MVC mode ====>
1. Mode database layer 2. View template Layer 3. Contron control layer-> operation method (logical layer)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~

Theoretical process for implementing the TP function ==> {method} for accessing the operation method, rather than accessing the page;

| Access: C layer. Operation Method | ----> | M layer | -- (return) --> | C layer | ----> | V layer |

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
@ Access operation: @ calls a method instead of a page @@@@
Path Method 1: path file name/Module name/controller name/Method
Get Method 2: get method: entry file? M = home & c = index & a = index
Method 3: rewrite mode: No entry file needs to be written;
Method 4: Combined with path + get:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
######################################## ######################################

D. Controller file (Implementation: display the template by calling the method ):
A controller (with a class method) -- control --> A template webpage
Content =>
Add 2 lines of code:
Namespace Home \ Controller;
Use Think \ Controller;
Access Method: (call $ this through an object)
Class MainController extends Controller
{
Public function test ()
{
$ This-> assign ()
$ This-> display ()!! You do not need to write parameters (Template File) because the method name is the same as the Template Name)
$ This-> show ()!! TP syntax
}
}
######################################## ######################################

E template layer: (the template folder structure is the same as the controller structure: controller name inclusion template = controller Inclusion Method)

1. template folder. 2. Creation of template files. Cause =>
1. A controller controls a template (because the method names may be the same, {template folder} must be differentiated)
2. Class method name. The generated object is the corresponding template file name.

1. template folder name. 2. Naming rules for template file names =>
1. template folder naming rules: Same as {controller;
2. Naming rules for template file names: Same as {class 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.