Can I use thinkphp5, as a layering?

before the code is written in Controller, too much writing is bloated, and it looks so messy. Now that I"ve changed it to this, I don"t know exactly how to calculate the industry standard. If it feels like this, it will be a little clearer.

controller\user.php

Class user extends Controller
{
    function reguser(){}
    function listuser(){}
}

logic\user\reguser.php
{}

logic\user\listuser.php
{}

model\user.php
{}

is it all right if I do this?

May.13,2021

as long as you want to subdivide, or your business needs to be subdivided, it can also be divided into several layers

  • Repository layer
  • Action layer
  • Service layer

I generally don't divide that much, just the Service layer (providing the overall framework basic services, such as SMS, HTTP requests, file processing, etc.), the model layer (building the processing model according to the system business), and then basically to the controller. Sometimes the data verification layer (validate) and the logical layer (logic) are written down, but usually not.
I think it's up to you to get used to it if you don't divide it. After all, in the eyes of others, the code is whether you like to understand it or not. Whatever. Personal opinion.

Menu