July 2017
Intermediate to advanced
456 pages
11h 32m
English
The Service Container has a great deal of flexibility when it comes to instantiating your service. Sometimes, however, this does not provide everything necessary to construct the service. When you need more specific control over this process, you can define a factory to instantiate the service. There are two ways to define this factory. First, you can define a factory service and define the function on that service to invoke:
http_client: class: GuzzleHttp\Client factory: http_client_factory:fromOptions
In this case, the class defined by the http_client_factory service has a member function, fromOptions(), that returns a GuzzleHttp\Client object.
The other option is to define the factory as a static function:
http_handler_stack: ...
Read now
Unlock full access