Questions tagged [zend-servicemanager]

30 questions
13
votes
3 answers

Zend Di vs ServiceManager dependency injection containers

What is DI for and what is its use case, when we have ServiceManager? They appear to be similar since in configuration files for both zend-di and zend-servicemanager we can set up some options such as aliases and invokables. I am trying to get a…
user1650441
  • 455
  • 3
  • 12
8
votes
2 answers

ServiceManager in ZF3

I know that this has been covered extensively in other threads, but I'm struggling to work out how to replicate the effect of $this->getServiceLocator() from ZF2 controllers in ZF3 ones. I have tried creating a factory using the various other…
4
votes
1 answer

How to place a class that requires a variable parameter into Dependency Injection container?

How to use Dependency Injection container when I have a variable non-static parameter that I need to supply? What I want in my code is this: $staff = $container->get(Staff::class); What I have now is this: $staff = new…
Dennis
  • 7,907
  • 11
  • 65
  • 115
3
votes
2 answers

How to get a service manager instance in a controller in zend framework 3?

I am trying to get a ServiceManager instance in my controller to use a factory for Db\Adapter. I added to module/Application/config/module.config.php: 'service_manager' => [ 'factories' => [ Adapter::class =>…
user5444681
2
votes
1 answer

Call Service With Options In Zend Framework 3

In ZF3, I am calling a form factory from a controller using this notation: $form = $this->formManager->get(myForm::class); not $form = new myForm(); In the factory, I'm using what ZF3 recommends for the method: public function…
jcropp
  • 1,236
  • 2
  • 10
  • 29
2
votes
2 answers

Circular dependency for LazyServiceLoader was found for instance `UserService`

In Zend Framework 2, I have a controller class UserController UserController is dependent on UserService UserService is dependent on UserChangedListener UserChangedListener is dependent on SomeOtherClass SomeOtherClass is dependent on…
1
vote
0 answers

How to inject service manager into a Model file in Zend Framework 3

I just upgraded one project to Zend Framework 3 from ZF 1.x version. In ZF 1.x version, we have implemented a functionality like provided an unique id for a request being made in the application using Zend Registry component, which is not there in…
1
vote
1 answer

ZF FactoryInterface - using options parameter for configuring loading dependencies

I am wondering about the best practices for loading complex objects. To begin with, i'm going to outline some boilerplate before getting to the problem. Assume the following: A simple domain model Client is loaded using a tablegateway, with…
1
vote
3 answers

Zend Service Manager - Service not found exception when trying to use phpdebugbar

I'm trying to use https://github.com/php-middleware/phpdebugbar in a clean Zend Expressive Skeleton application. I know the instructions on this page suggest using this DI configuration (if using…
d.lanza38
  • 2,525
  • 7
  • 30
  • 52
1
vote
1 answer

Zend Framework 3 Rendering HTML For HTML Email

Is there any method for getting html content of a view in a controller? I am trying to send html email from ZF3,however, I have not find any method for fetching html content to controller. I used controller render method, $render = new…
1
vote
1 answer

How to include EntityManager in ZendFramework 2 AbstractValidator

I have a custom validator, extending Zend AbstractValidator. The thing is, i want to include Doctrine EntityManager, but i keep failing! I tried to make a Factory for my Validator, but it doesn't seem to work. Help!! What am I doing…
user7867306
1
vote
0 answers

What are the reasons for PHP Frameworks to use a Dependency Injection Container for object instantiation?

I am going to focus on Zend Framework, becasue I know it best, but this is certainly applicable to other similar mechanisms found in other PHP Frameworks that use an Inverstion of Control container. In case of Zend Framework, with a bit of…
Dennis
  • 7,907
  • 11
  • 65
  • 115
1
vote
1 answer

Migrating ZF2 to ZF3: Zend\Mvc\Router\Http\Segment was not found in the plugin manager

I'm migrating a ZF2 application to ZF3. First I was getting the error: Fatal error: Uncaught Zend\ModuleManager\Listener\Exception\RuntimeException: Could not find a valid ServiceManager for RoutePluginManager in…
automatix
  • 14,018
  • 26
  • 105
  • 230
1
vote
2 answers

serviceLocator is null

class CustomSawException extends Exception implements ServiceLocatorAwareInterface, SawExceptionInterface { protected $serviceLocator; public function test(){ $this->serviceLocator->get('SomeThing'); } /** * Set…
user1272855
  • 82
  • 1
  • 8
0
votes
1 answer

Implementing services

I'm quite new to Laminas API tools, i'd like to understand how inject properly a service into my rest service. Example: namespace account\V1\Rest\Users; use Laminas\ApiTools\DbConnectedResource; class UsersResource extends DbConnectedResource { …
sfeb
  • 11
  • 1
  • 1
1
2