Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9249927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:19:14+00:00 2026-06-18T10:19:14+00:00

I want to put the doctrine entity manager into many different classes in my

  • 0

I want to put the doctrine entity manager into many different classes in my ZF2 project. Thus. I have setup the following initializer in my Module.php:

'initializers' => array(
      function ($instance, $services) {
            if (is_object($instance)) { // just for debugging
                var_dump(get_class($instance));
            }
            if (!$instance instanceof EntityManagerAwareInterface) {
                return;
            }

            $entityManager = $services->get('doctrine.entitymanager.orm_default');
            $instance->setEntityManager($entityManager);
        },
    ),
)

Yet, it never gets called on my AuthController even though I am visiting a site of that controller (and get a null pointer exception, because the entity-manager was not set). Of course, the controller does implement the required interface:

class AuthController extends AbstractActionController implements EntityManagerAwareInterface

Is there anything else I have to configure so that my AuthController is checked against the initializer closure?

At the moment I have it under invokables in module.config.php.

'controllers' => array(
    'invokables' => array(
        'Auth\Controller\Auth' => 'Auth\Controller\AuthController',
    ),
),

When I remove it from there, the application cannot find the class anymore.

My debugging output lists other classes which are checked against the initializers, many managers and services. A small excerpt:

string(37) "Zend\\Mvc\\Controller\\ControllerManager"
string(33) "Zend\\Mvc\\Controller\\PluginManager"
string(29) "Zend\\View\\HelperPluginManager"
[...]
string(24) "Doctrine\\DBAL\\Connection"
string(26) "Doctrine\\ORM\\EntityManager"
string(41) "Zend\\Authentication\\AuthenticationService"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:19:16+00:00Added an answer on June 18, 2026 at 10:19 am

    Try adding an initializer for the controller manager too, judging by your debug output, the one you posted appears to be for the service manager. You configure other managers the same way, the method to use for controller manager is getControllerConfig

     public function getControllerConfig()
     {
          return array(
              'initializers' => array(
                  // controller initializers here...
              ),
          );
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a many-to-many relationship defined in my Symfony (using doctrine) project between Orders
Suppose, I have very large foreach loop. I want put this loop into try
hey, hi i want put limit on object creation means a class can have
I want to put two side by side on another (I have three )
I want to put the apk file into the Kindle Fire storage(through USB cable)
I want to put all my resources into a ClientBundle for easy management. So
I want put a value from front of the list into an another list
I have a RadioGroup and two RadioButtonField added in a VerticalFieldManager. I want put
I have a Symfony2 project with its own database, and now I want to
I want put this two value together (Side by side), as following image, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.