Original: thinkphp Learning note 1-directory structure and naming conventions
Recently began to learn thinkphp, in the next, a lot of problems do not understand so I want to take out, I would like to be bold in the homepage, I hope to see people can answer questions for me, so that we have an interaction, learn quickly, do not have his meaning, so-called live to the old, learn old, hope you don't laughed at AH.
My approach is very simple, starting from the manual, the manual is the development of thinkphp author hard work results, but some places are not understand, if you are fortunate to encounter similar problems hope to reply. thinkphp Manual Address: http://doc.thinkphp.cn/manual.html
1. Framework Catalogue
In chapter 1.6 of the directory structure, the contents are as follows:
The new version of the directory structure on the original basis of the adjustment, more clear.
Catalog/File |
Description |
thinkphp.php |
Frame Entry File |
Common |
Framework Common Files Directory |
Conf |
Framework configuration file Directory |
Lang |
Framework System Language Directory |
Lib |
System core base Class Library Directory |
Tpl |
System Templates Directory |
Extend |
Framework Extensions directory (for more information on extended directories, refer to the Extensions section later) |
Note: If you are downloading a core version, it is possible that the extend directory is empty because the thinkphp itself does not depend on any extensions.
If we open the thinkphp directory under the main directory, the main content as mentioned above, such as 1:
Figure 1
It can be found that the core base Class library has not been called Lib, this is the library, the extend directory, said to be the framework extension directory, and also special hints in the core version of this directory is empty, But I did not find this extend directory in the two versions of ThinkPHP3.2.2 core and ThinkPHP3.2.2 full version. As follows:
Figure 2: Full version of the catalogue
Fig. 3. Core Edition Directory
If we open the entire directory to see the content below, if 4
Figure 4: Full Catalog
Here we can see the other files directory, fortunately, the author in addition to the framework directory thinkphp in other directories have put a readme.md file to tell us what this directory is to do,
1.Application: Project directory
2.Public: Resource files directory, should put Css,js and pictures
3.ThinkPHP: Frame directory, this is the core class that is placed here
4..htaccess: A distributed configuration file, just touch this file feel very complex, here is not specifically about the function of this file
5.INDEX.PHH: Entry File
6.README.MD: This Readme file
2. Naming rules
1. The class name ends with a. Class.php and is named after the hump, which is very rare, perhaps because the author wrote Java for a while to write the framework, and some things in Java to get here, so I am very rare, because I wrote for a long time. NET, hehe, hated the following line of words to name the way, feel Let a person read an array of the following underlined, hemp is not troublesome, directly read a few words than to read an array simple Ah, but the way to name the underscore PHP is the habit of the inventor, we have to reluctantly accept.
2. Case, I remember that the custom variables in PHP are case-sensitive, the others do not distinguish, but in order to avoid the case we switch between the words, suggest or distinguish, I think I can use lowercase as far as possible in lowercase, go to school to do English reading comprehension there is no very annoying to appear uppercase words, have wood?
3. The class name and file name are consistent, and this one also likes to see the file name to know the class name, as well as the. NET rules.
4. The name of the function is underlined in lowercase letters such as:get_client_ip, why do not use the hump or Pascal naming method, this is not more in line with the reading habits.
5. Constants, language parameters, configuration parameters are uppercase and underlined, the same is not used to read up the brain.
thinkphp Learning Note 1-directory structure and naming conventions