Thinkphp entry 1 (45)

Source: Internet
Author: User
: This article mainly introduces Thinkphp entry 1 (45). If you are interested in the PHP Tutorial, refer to it. What is a framework?

It is a collection of code that can include variables, constants, functions, classes, and so on. These codes are closely related to each other and cooperate with each other. There are also Design Patterns: MVC, Singleton, and factory.

Why learning frameworks?

1. all our energy can be concentrated at the business level, saving about 60% of the workload.

2. this function helps us quickly, stably, and efficiently build a program system.

3. the system's robustness, maintenance, flexibility, and adaptability to customer needs have been greatly enhanced

Mature framework

1. zendFramework: the official framework. Weight

2 Yii: OOP weight

3 cakephp: medium volume

4 symfony weight

5 CodeIgniter lightweight

6 ThinkPHP lightweight

7. there are still many unknown frameworks.

When to use the framework

1. there are a lot of program Project code and complicated functions.

2. the project time is very short.

Application Catalog description

Project Application

Description of The boke application directory (the directory automatically created after the program runs)

Application entry file:

MVC design pattern

Entry program file

C: controller

V: view

M: model

Compile cache files ~ Runtime. php

The tp Framework compiles many files to be loaded by the system into one file for performance consideration. This file is ~ Runtime. php, which saves a lot of overhead for opening and disabling files.

Code Tracing:

1. index. php entry

2. ThinkPHP. php

3. ThinkPHP/Common/runtime. php

4. Think: Start (); ThinkPHP/Lib/Core/Think. class. php

L Think: buildApp ()

L App: run () ThinkPHP/Lib/Core/App. class. php

5 App: run ()

L App: exec ();

The reflection mechanism is used to instantiate the controller object and call the corresponding method.

Note:

Our css, js, img images and other website resources need to be accessed separately.

Web requests through routing

Template creation:

Controller call Template display content:

  1. Call a specific template through display ()
  2. Create a template file under the Tpl Directory
  3. Modify the css and img Image directory addresses of the template file and the css Image address
  4. Create css, img, and js constants in the index. php file for the template.

Current Portal file:

Summary:

  1. Create an application using the tp framework and create an entry File (go/index. php)
  2. Create multiple controllers, refer to index controller. All controllers inherit the Action parent class.
  3. Use the controller to call the View template display ()
  4. Display template content

Create a template under Tpl

Modify the directory address of css and img

The above introduces Thinkphp entry 1 (45), including some content, and hopes to help those who are interested in PHP tutorials.

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.