What does the service layer in the thinkphp framework do?

Source: Internet
Author: User
What the hell is this layer, see the next thinkphp and symfony all have this gratitude, but the service of the two frameworks make people understand as if completely two different things.
I understand that the Symfony service is a variety of third-class libraries, and thinkphp I understand that he is equivalent to each C and M of the middle tier, each control will be to the serivce. Really a little confused, ask the great God to give guidance?

Reply content:

What the hell is this layer, see the next thinkphp and symfony all have this gratitude, but the service of the two frameworks make people understand as if completely two different things.
I understand that the Symfony service is a variety of third-class libraries, and thinkphp I understand that he is equivalent to each C and M of the middle tier, each control will be to the serivce. Really a little confused, ask the great God to give guidance?

What I've been doing recently is just the thinkphp 3.2.x version; As for Symfony not very familiar with some of the libraries, so it is not caught dead.

As I understand it, the service in TP can be understood as the API, not like the LZ understanding of C and M of the middle tier, the M layer is used to interact with the database, and the service is not limited to this, the role is to provide the controller or other things a standardized "service" Interface for use (service).

For example, "user""department" two model, respectively, corresponding to its curd operation of the data table. "userservice" provides "authroize", "get_department", "is_authenticated" and other "service Interfaces". It is nothing more than the original model to do more detailed separation, including the TP logic is the same, although not how to use it.

SF First answer, caught dead.

Above

This means that so far, the size of your project has been small, MVC basically fits your needs, and when your project size or complexity goes up, you will naturally have the serivce layer of demand.

With @ old FA Hai said

Symfony2 called service Container (Services container), server capacity and service in thinkphp is an idea, but there are some differences:

The thinkphp usually have these layers:

Controller
Model
View
Service
...

These layers are in the Symfony2:

Controller
Entity
Repository
View
Manager

The manager in Symfony2 is not required, basically and the service in thinkphp is a thing that is between the Controller and model (repository), and the service container is built on the Manager A service.

  • 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.