What is the service layer in the thinkPHP framework?

Source: Internet
Author: User
What exactly is this layer? I have read Thinkphp and symfony, but the services of these two frameworks seem to be totally different. I understand that symfony's service is a variety of third class libraries, and thinkphp I understand that it is equivalent to the middle of every c and m... what exactly is this layer? I have read Thinkphp and symfony, but the services of these two frameworks seem to be totally different.
I understand that symfony's service is a variety of third class libraries, and thinkphp I understand that it is equivalent to the middle layer of every c and m, each control will have a proper serivce. I am a little confused. Could you please give me some advice?

Reply content:

What exactly is this layer? I have read Thinkphp and symfony, but the services of these two frameworks seem to be totally different.
I understand that symfony's service is a variety of third class libraries, and thinkphp I understand that it is equivalent to the middle layer of every c and m, each control will have a proper serivce. I am a little confused. Could you please give me some advice?

ThinkPHP 3.2.x is just used recently. As for symfony, it is not very familiar with other libraries, so it is not ugly.

In my understanding, services in TP can be understood as APIS, rather than the middle layers of C and M as LZ understands. M layers are used to interact with databases. in Service, this is not limited to providing a standardized "Service" interface for the Controller or other things ).

For example, the two models "User" and "Department" correspond to their CURD operations on the data table respectively. "UserService" provides "service interfaces" such as "authroize", "get_department", and "is_authenticated 」. It is nothing more than separating all the previous tasks made by the Model in more detail, including the Logic in the TP, although it is not used at present.

SF's answer is ugly.

Above

This shows that the scale of the project you have reached is still small, and MVC basically meets the requirements. When the scale or complexity of your project increases, you will naturally have this requirement on the Serivce layer.

Same as @ old Fa Hai

Symfony2 is called Service Container (service Container). The Service in server and thinkphp is an idea, but there are some differences:

Thinkphp generally has these layers:

Controller
Model
View
Service
...

These layers are in Symfony2:

Controller
Entity
Repository
View
Manager

The Manager in Symfony2 is not necessary. Basically, the service in Thinkphp is something between the controller and model (repository), and the service container is a service built on the manager.

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.