Brief introduction to ThinkPHP3.1.3 using notes (1)

Source: Internet
Author: User
Tags constant extend php file php framework

The framework is just a tool. It just sorts out the commonly used code in a certain pattern. It facilitates rapid development by programmers and team coordination. However, the framework is based on language. If you don't even know how many Super global variables PHP has, you still need to go back and lay a solid foundation. Make sure that the server is not cut by mistake.

One of my predecessors said that reading highly handwritten code is the best shortcut for programmers to quickly improve. Indeed, if you write a simple addition, modification, deletion, and query, you may always be a low-level programmer (also write programmers, also write programmers ).
Think out of limits boldly. You need to change the framework when you try to learn it yourself. Actively use echo, print_r, var_dump, and so on. When you control the framework, you can modify it according to your actual needs. It is a great tool for you to complete the project. Just like riding a car, you can buy a whole car first. When you fully understand it, you can build a car according to your own needs.
Interest is the greatest motivation for learning. If you like it, stick to it. I think the happiness index of most people in today's society is very low. Although work is a means of life, it is also something that will accompany you for a lifetime. Don't do your work for decades, it's no pleasure to look back.
ThinkPHP: PHP, MySql, and MVC.
Before we talk about ThinkPHP framework caching, I would like to say that ThinkPHP is definitely an excellent framework comparable to CI. It is also the best PHP framework in China.
TP has a constant APP_DEBUG, which is located in the ThinkPHP. php file.
This constant is used to set whether to enable the debugging mode. We can customize it before introducing the entry file. If this parameter is set to FALSE, a copy of the value is generated in the runtime folder ~ Runtime. php file (both the path and file name can be modified ). However, the comments, spaces, and line breaks are removed from the file. It is too troublesome to directly read this document.
View the source code. We can find a function in runtime. php: build_runtime_cache (). The strip_whitespace () function is used before writing data to the cache (). Modify the source code and remove this function. Then re-compile. You will find that ~ The content in runtime. php is clear at a glance. Listed below

The code is as follows: Copy code
$ GLOBALS ['_ inintime'] = microtime (TRUE );
Defined ('app _ name') or define ('app _ name', 'home ');
Defined ('app _ path') or define ('app _ path', 'Home /');
Defined ('app _ debug') or define ('app _ debug', false );
Defined ('memory _ LIMIT_ON ') or define ('memory _ LIMIT_ON', true );
Defined ('think _ path') or define ('think _ path', 'd: \ workplace \ llbook \ Source \ ThinkPHP /');
Defined ('runtime _ path') or define ('runtime _ path', 'Home/RUNTIME /');
Defined ('runtime _ file') or define ('runtime _ file', 'Home/RUNTIME /~ Runtime. Php ');
Defined ('think _ version') or define ('think _ version', '3. 1.3 ');
Defined ('Magic _ QUOTES_GPC ') or define ('Magic _ QUOTES_GPC', false );
Defined ('is _ CGI ') or define ('is _ CGI', 0 );
Defined ('is _ win') or define ('is _ win', 1 );
Defined ('IS _ CLI') or define ('IS _ CLI', 0); www.111cn.net
Defined ('_ PHP_FILE _') or define ('_ PHP_FILE _', '/llbook/index. Php ');
Defined ('_ ROOT _') or define ('_ ROOT _', '/llbook ');
Defined ('URL _ common') or define ('URL _ common', 0 );
Defined ('URL _ pathinfo') or define ('URL _ pathinfo', 1 );
Defined ('URL _ rewrite') or define ('URL _ rewrite', 2 );
Defined ('URL _ compat') or define ('URL _ compat', 3 );
Defined ('core _ path') or define ('core _ path', 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib /');
Defined ('extend _ path') or define ('extend _ path', 'd: \ workplace \ llbook \ Source \ ThinkPHP/EXTEND /');
Defined ('mode _ path') or define ('mode _ path', 'd: \ workplace \ llbook \ Source \ ThinkPHP/Extend/MODE /');
Defined ('engine _ path') or define ('engine _ path', 'd: \ workplace \ llbook \ Source \ ThinkPHP/Extend/ENGINE /');
 
Defined ('vendor _ path') or define ('vendor _ path', 'd: \ workplace \ llbook \ Source \ ThinkPHP/Extend/VENDOR /');
Defined ('Library _ path') or define ('Library _ path', 'd: \ workplace \ llbook \ Source \ ThinkPHP/Extend/LIBRARY /');
Defined ('Common _ path') or define ('Common _ path', 'Home/COMMON /');
Defined ('Lib _ path') or define ('Lib _ path', 'Home/LIB /');
Defined ('conf _ path') or define ('conf _ path', 'Home/CONF /');
Defined ('Lang _ path') or define ('Lang _ path', 'Home/LANG /');
Defined ('tmpl _ path') or define ('tmpl _ path', 'Home/Tpl /');
Defined ('HTML _ path') or define ('HTML _ path', 'Home/HTML /');
Defined ('log _ path') or define ('log _ path', 'Home/Runtime/Logs /');
Defined ('temp _ path') or define ('temp _ path', 'Home/Runtime/TEMP /');
Defined ('data _ path') or define ('data _ path', 'Home/Runtime/DATA /');
Defined ('cache _ path') or define ('cache _ path', 'Home/Runtime/CACHE /');
Set_include_path (get_include_path (). PATH_SEPARATOR. VENDOR_PATH );
Common. php // file content
Think {}
ThinkException {}
Behavior {}
ReadHtmlCacheBehavior {}
CheckRouteBehavior {}
ParseTemplateBehavior {}
ContentReplaceBehavior {}
TokenBuildBehavior {}
WriteHtmlCacheBehavior {}
ShowRuntimeBehavior {}
ShowPageTraceBehavior {}
Alias_import (array (
'Model' => 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Core/Model. class. Php ',
'DB' => 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Core/Db. class. Php ',
'Log' => 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Core/Log. class. Php ',
'Thinktemplate' => 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Template/ThinkTemplate. class. Php ',
'Taglib' => 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Template/TagLib. class. Php ',
'Cache' => 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Core/Cache. class. Php ',
'Widget '=> 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Core/Widget. class. Php ',
'Taglibcx' => 'd: \ workplace \ llbook \ Source \ ThinkPHP/Lib/Driver/TagLib/TagLibCx. class. Php ',
));
Functions. php
Log {}
Dispatcher {}
App {}
Action {}
View {}
L () // language setting function
G ('loadtime ');
Think: Start (); // Start

The reason for this effort is that I want to check whether the framework contains the files needed during running. This means that the above files can be referenced directly when writing the project. TP is to disrupt files according to various rules and conditions, and perform factory processing according to the MVC mode. But you must introduce the files one by one when using them. You can regard them as a file in ThinkPHP. php. We can also see that it loads the most basic configuration files, function files, and class files. The configuration files and function files in the project file are also introduced through functions (not configured here), while class files such as Action files and Module files are dynamically obtained through url routing rules. From this cache file, we can also see that TP has many agreed rules, such as naming rules and path rules. I think when using TP, we must understand how TP separates and develops files with different behaviors, and how to use path rules to properly introduce files as needed. All subsequent projects are based on the code in the above file. It is necessary to learn this code.
So how can I deploy a project using the framework? I think the flexibility of TP provides us with a lot of options. Because a project is generally divided into foreground and background. We can deploy the two to a project folder by grouping, but I think this is unwise.
For project groups, I think the foreground and background should be completely separated and placed in two document trees. The framework is shared, but the core code should be separated.

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.