ThinkPHP study notes: installation configuration, thinkphp study notes _ PHP Tutorial

Source: Internet
Author: User
ThinkPHP learning notes: installation configuration and thinkphp learning notes. ThinkPHP learning notes installation configuration, thinkphp learning notes domestic framework thinkPHP, is a MVC framework, this framework initially simulates the JAVA struts framework, install and configure thinkPHP learning notes using a single portal file. thinkphp learning Notes

The domestic framework thinkPHP is an MVC framework, which initially simulates the struts framework of JAVA, simulates JAVA filters using a single entry file, and uses action to simulate STRUTS controller ACTION, in MVC, M is model, V is view, and control is action.

In version 3.2.3, control is changed to C, which also tends to be a form. springMVC in the JAVA world is becoming popular. spring uses control instead of action, in fact, "action" indicates that "control" is misleading. "control" means "C". why is "aciton" confusing.

Thinkphp's most difficult to understand is his access method. it is misleading to explain it in the official document. according to the official document, it must be wrong because the official document has not been clearly stated!

Thinkphp installation is actually very simple. as long as the main program file is require, some column directories can be generated. but what is the relationship between the URL and its control and tpl? The official text is too vague, but anyone who has used JAVA will be fooled by the official text to vomit blood!

Guan Wen, is it clear !?

The following points are summarized after actual use:

1. install thinkphp:

You can create admin. php or other names in the same directory as the main program thinkPHP.

The code is as follows:
<? Php
// Define the project name and path
Define ('app _ name', ''); // The prefix is not added before the generated folder.
Define ('app _ path', './admin/'); // This indicates that the admin directory is generated in the same directory as the main program THINKPHP.
Define ('app _ debug', true); // start the editing mode. the file is forcibly compiled and not cached.
// Load the framework entry file
Require ("../ThinkPHP. php"); // Main program entry file

2. file directory:

The automatically generated file directory is

Common: where the function is written

Conf: configuration file, for example, configuring the database connection address

Lang: Language Pack, International

Lib: action, model are all in this area, which is a very important part. it is completely different from JAVA's lib, which is a JAR package.

Runtime: cache file at runtime

Tpl: template, which is an html file

3. access method:

URL: localhost/thinkphp/admin. php? M = Show & a = add

Explanation: Local/project directory/single portal file just created? Model = class name & action = method name

Enter the add method in the Show class in the admin. php file of a single portal.

Note: the class name starts with an upper-case letter and cannot be found in lower-case letters. this hurt me. after an afternoon, I only knew the upper-case class name, but I didn't know the lower-case class name.

Infopath URL: localhost/thinkphp/admin. php/Show/add

Explanation: like the default one, m a is not written.

4. write class:

Thinkphp's author must be a perfectionist who is fond of tossing, so he will think about how to control the program. The whole program is centered on the action class, an action class is equivalent to a page. the method in it is operations related to this page. What are the addition, deletion, modification, and query operations? this is very suitable for Chinese people, but the reusability is not high.

Write file: lib/action/ShowAction. class. php

The code is as follows:
<? Php
// Show is the class name. Action is only an aid in recognition and must be written. However, it can be ignored when it can be called. remember to use uppercase letters. if you use lowercase letters, it will also start with uppercase letters, so that you cannot find the lower-case show module, m = Show
Class ShowAction extends Action {
// Add is the action method, a = add
Public function add (){
// An error is returned if no quota is found.
$ This-> display ('CC ');
}
}

5. write a template:

As mentioned above, to load the template, write one:

Tpl/Show/cc.html

The code is as follows:
A common HTML file

The above is all the content of this article. I hope you will like it.

The domestic runtime framework thinkPHP is an MVC framework, which initially simulates the JAVA struts framework and uses a single portal file to simulate it...

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.