Home  >  Q&A  >  body text

Newcomers are not very clear about some concepts of PHP symfony2

1. The concept of event, for example, in what scenarios will event be used?
2. Regarding the concept of monitoring, it is also unclear what application scenarios would be better to use monitoring.
3. The concept of DI (injection), is the service introduced when it is needed? How is it different from ordinary public functions?

高洛峰高洛峰2604 days ago643

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-06-29 10:10:20

    1. event has many uses, such as processing user login completion (writing login log?), user payment completion processing (issuing payment notification?) and many more.

    2. Listening is the opposite of an event. An event has a listener (that is, the operation performed after the event is triggered (fire)). The event mechanism can be used to decouple the code.

    3. Dependency injection is a big concept. You can search to learn more about it. There are two general benefits:
      (1). Decoupling
      (2). Convenient for unit testing and mocking

    reply
    0
  • Cancelreply