Thinkphp5 Letu CRM project source code structure

The CRM project chooses the ThinkPHP5.1.x version for development, and the PHP version is PHP7+.

Now doing PHP projects, I like to structure the code of the project into a project with high availability. For example, I have contacted many people who use ThinkPHP to do projects, and they always do projects according to the directory structure generated by TP's official default. This is not too serious. The most serious part is that the public Model layer, Logic layer, or Dao layer is not strictly added to his architecture. As a result, many simple or complex codes are directly implemented in the Controller layer. Finally, it is written that the same function has to be copied and pasted directly, causing a lot of redundant code to appear in the project, which brings trouble to later expansion and maintenance.

This picture is the code of TP3.2 written by others,

This picture is the code I wrote with TP3.2 very early. The Controller layer is only responsible for organizing the submitted data and passing it to the Model layer or Logic layer.

Let's take a look at the CRM project structure made with TP5.1 now, which is divided into Controller layer, Model layer, Logic layer, and Dao layer. The structure is clear and the code is reused to reduce redundant code.

The Model layer corresponds to the table entities in the database

After this architecture, I can reuse the business logic written in the Logic layer, whether it is the web side, the web side of H5, or the api of the app.

Comments and exchanges are welcome. If there is any reprint, please indicate the original author and source.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324112698&siteId=291194637