Home headlines Illustrated ThinkPHP5 framework (1): basic knowledge, development specifications and directory structure

Illustrated ThinkPHP5 framework (1): basic knowledge, development specifications and directory structure

May 29, 2018 am 09:31 AM
php thinkphp5

Based on the latest ThinkPHP5.0.8, it was originally produced by xmind mind map. If you feel that the picture is not clear, you can download the xmind source file and open it with xmind software.

In addition, the source code used in the mind map is all in the map notes. You can only see it if you download the xmind source file.

Students who want to learn ThinkPHP5 development by themselves must not miss this benefit. Programmers who are working on the ThinkPHP5 project development can save it for future inquiries

1. Mind map: (It is recommended to click on the picture to open a new page for viewing or download it for local viewing)

Illustrated ThinkPHP5 framework (1): basic knowledge, development specifications and directory structure

2. Text description of the map:

thinkphp5 basics

1 What is tp5?

1.1 Free and open source, fast and simple object-oriented lightweight PHP development framework

1.2 Simple and practical, with minimal code, allowing it to be used to develop commercial projects

1.3 A new architecture, compared with version 3.2, is a brand new product

1.4 tp5 is suitable for new project development, not suitable for old project upgrades

2 Installation method

2.1 Official website Download: thinkphp.cn, core version and full version are provided

2.2 composer installation:

2.2.1 windows: you need to download the composer tool

2.2.2 mac or linux :Terminal tool online installation

2.3 git installation (recommended):

3 Development specifications

3.1 Naming specifications

3.1.1 Camel case nomenclature: by Multiple words with capital letters

Big hump: The first letter of the first word is capitalized

Small hump: Except for the first word, the first letter of each other word is capitalized

3.1.2 Hungarian nomenclature: use _underscores to connect words

Prefix: the first word is a prefix or prefix abbreviation, indicating the type or function: o_Div

Meaningless: between multiple words Underscores are used in intervals, purely to separate words, without clear meaning: user_name

3.2 Directory and file

3.2.1 Directory: lowercase letters + underline: app_index

3.2 .2 Class libraries and function files are uniformly suffixed with .php: func.php

3.2.3 Class file names are defined in namespaces, and the path of the namespace is consistent with the path of the class library file

3.2.4 Class file name: CamelCase naming, consistent with the class name,

3.2.5 Class file name: CamelCase, other files are named in lowercase + underline: User, my_file.php

3.3 Functions, classes, and attribute naming

3.3.1 Use lowercase letters and underlines for functions: get_user_level()

3.3.2 All methods and attributes in the class use lowercase letters. Camel case: getUserName(), tableName

3.3.3 All magic methods in the class begin with double underscores, consistent with PHP official requirements: __callStatic()

3.4 Constants and configuration

3.4.1 Constants: uppercase letters + underline, APP_PATH

3.4.2 Configuration parameter name: lowercase letters + underline, url_route_on

3.5 Data tables and fields

3.5.1 Lowercase letters + underline: user_table

4 Directory structure

mark: The directory structure can be customized

4.1 application: application directory

1 common: public module directory (Optional and can be changed to inaccessible)

2 extra: extension module

3 index:default module

4 module_name:user module

4.1 config. php:Module configuration file

4.2 common.php:Module function file

4.3 controller:Controller directory

4.4 model:Model directory

4.5 view :View directory

5 command.php:Command line tool configuration file

6 common.php:Public function file

7 config.php:Public configuration file

8 database.php: Database configuration file

9 route.php: Routing configuration file

10 tags.php: Application behavior extension file

4.2 extend: extension Directory (empty)

4.3 public: Web deployment directory, externally accessible

4.3.1 static directory: static resource library (css, js, image)

4.3. 2 index.php: Application entry file

4.3.3 router.php: Used for PHP’s own webserver support and can be used for quick testing

4.3.4 robots.txt: Search engine crawler file

4.3.5 .htaccess: used for apache rewrite file

4.4 runtime: application running directory

4.4.1 log: log directory

4.4 .2 Temporarily generated files

4.5 thinkphp:framework system directory

4.5.1 lang:language pack directory(zh-cn)

4.5.2 library:framework core Class library directory

1 think class library package directory

2 System Traits directory

4.5.3 tpl: System template directory

1 default_index.tpl: Default homepage template

2 dispatch_jump.tpl: Page jump template

3 page_trace.tpl: Page debugging information display template

4 think_exception.top: Page exception information template

4.5.4 CONTRIBUTING.md: How to contribute your code

4.5.5 LICENSE.txt: License Agreement

4.5.6 README.md:readme file

4.5.7 base.php:Basic definition file

4.5.8 console.php:Console entry file

4.5.9 convertion.php:Framework convention configuration file

4.5.10 helper.php: Helper function file

4.5.11 phpunit.xml: phpunit configuration file (related to tests directory)

4.5.12 start.php: Framework entrance File (load base.php file)

4.6 vendor: third-party library directory

4.7 tests: test directory, you can ignore it for now

4.8 build.php :Automatically generate definition files (reference)

4.9 composer:composer definition file

4.10 think:Command line entry file

4.11 LICENSE.txt: Authorization description file

4.12 README.md: Description file written in MarkDown

3. Mind map source file download (xmind format):

Illustrated ThinkPHP5 framework (1): basic knowledge, development specifications and directory structure##1.tp5 basics. xmind.zip

【Related recommendations】

1.

Illustration of ThinkPHP5 framework (2): Application running process and life cycle

2 .

Illustrated ThinkPHP5 framework (3): Configuration class Config.php source code interpretation

3.

The latest 10 thinkphp video tutorial recommendations in 2017

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.