thinkphp Primer One (45)

Source: Internet
Author: User

What is a framework?

is a collection of code that can have variables, constants, functions, classes, and so on. These codes are closely related to each other and have a cooperative relationship. There are also design patterns: MVC, Singleton, Factory, and so on.

Why study the framework?

1. All our energies can be focused on the business level, can save about 60% of the workload

2. This function can help us to set up the program system quickly, stably and efficiently.

3. Robust, maintenance, flexible and adaptable to customer needs

Mature Framework

1 Zendframework: Official framework. Weight

2 Yii:oop Weight

3 cakephp: Medium volume

4 Symfony Weight

5 CodeIgniter Light Weight

6 thinkphp Light Weight

7 and so on, there are many unknown frameworks.

When to use frames

1. The program project code is very many, the function is very complex.

2. Project time is very tight.

Application Directory Description

Project Application

Boke application Directory Description (the directory created automatically after the program is run)

Application's entry file:

MVC design Pattern

Entry Program Files

C: Controller Controllers

V: Views View

M: Model

Compiling cache files ~runtime.php

is the TP framework for performance considerations, the system needs to load a lot of files are compiled into a file inside, this file is ~runtime.php, so that the system saves a lot of file open, shutdown overhead.

Code tracking:

1. index.php Entrance

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 ();

Using the reflection mechanism, instantiate the controller object and call the corresponding method

Attention:

Our CSS, JS, img images and other site resources, need to be accessed separately.

Making Web requests through routing

Template creation:

The controller calls the template to display the contents:

    1. Invoking a specific template through display ()
    2. Create the corresponding template file below the TPL directory creation
    3. Modify template file css and img image directory address, CSS style image address modification
    4. Make CSS, IMG, JS constants for template use in portal file index.php
Now the entry file:

Summarize:
    1. Create an application using the TP framework and make a portal file (go/index.php)
    2. To create multiple controllers, refer to the index controller. All controllers have inherited action parent class
    3. Call the view template display () through the controller
    4. Show Template content

Create a template below the TPL

Modify CSS, img corresponding directory address

thinkphp Primer One (45)

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.