This article mainly introduces a domestic MVC framework thinkphp, here is the thinkphp installation and configuration, as well as a simple example, the need for small partners can refer to.-->
The thinkphp framework is an MVC framework that initially simulates the Java Struts framework, uses a single entry file to simulate Java filters, and uses action to simulate struts controller action, so why is it that in his MVC, M is model,v is view, and control is the cause of action.
In version 3.2.3, the control was changed to C, and it tended to form, because the SPRINGMVC of the Java World began to become popular, and spring used control, which did not use the definition of action, in fact, the action to indicate control itself is a certain misleading, control on C Well, why a aciton, let a person not touch the mind.
Thinkphp the most difficult to understand is his access, in the official document explained a bit misleading, according to Guanven must be wrong, because Guanven did not speak clearly!
thinkphp installation is actually very simple, as long as require his main program files, you can generate some columns of the directory, but the URL and his control, TPL's relationship is what? Guanven said it is too vague, whenever the use of Java people will be the official text to vomit blood!
Guanven, can you be more organized?
After actual use, the following points are summarized:
1, install thinkphp:
and the main program thinkphp the same directory to create admin.php or other names can beThe code is as follows:
2, File directory:
The automatically generated file directory is
Common: Where to write functions
Conf: Configuration files, such as configuring database connection addresses
Lang: Language packs, internationalization
Lib:action,model are all in here, is a more important place, and Java Lib is a jar package completely different concept
Runtime: Cached files at run time
TPL: template, HTML file
3, access method:
Explanation: Local/project directory/The single entry file just created? Model= class name &action= method name
Add method in show class in admin.php of single entry file
Emphasis: Class name is the beginning of uppercase, lowercase will not find, this put me to the bitter, and made a afternoon, the original is only recognized capital class name, lowercase do not know
InfoPath style Url:localhost/thinkphp/admin.php/show/add
Explanation: The same as the default, is not write M A
4, write class, write method:
Thinkphp's author must be a person who likes to toss, perfectionist, so will think out this way to control program, the whole process is to action class as the core, an action class equals is a page, the inside method is and this page related operation, what additions and deletions change check ah, This is in line with the Chinese way of thinking, but the reusability is not high.
Write file: lib/action/showaction.class.phpThe code is as follows:
5, write the template:
The above mentioned the load template, now write a:
Tpl/show/cc.htmlThe code is as follows:
The above is the entire content of this article, I hope you can enjoy.