Search code examples
service-locator

What is difference between factory and invocable services in zend2?


Can anyone describe in depth what is difference between factory and invocable services in zend2. Can invocable service accpet constructor?


Solution

  • – “invokables” tells to the ServiceManager to instantiate the class when it’s needed.

    – “factories” is simillar to the “invokables” but it should be used when you need some additional configuration, as you can see in the examples you mentioned in your question.