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 9173245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:32:41+00:00 2026-06-17T16:32:41+00:00

Hello I am trying to instantiate a class controller of another class controller of

  • 0

Hello I am trying to instantiate a class controller of another class controller of a different module (created by me) that I am using but I can’t do it because I get the message:

Class ‘ZfCommons\Controller\MyAbstractActionController’ not found in
…..

and it is when I execute the command use ZfCommons\Controller\MyAbstractActionController;

The file that contents the class MyAbstractActionController the first command is:

namespace ZfCommons\Controller;

I guess I would have to do a require or include in PHP,but working with ZF2 I think maybe there is a more elegant way to do that.

How can I do it? Maybe I am using something wrong.
If you need to view more code I can copy and paste.

  • 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-17T16:32:43+00:00Added an answer on June 17, 2026 at 4:32 pm

    If you just want to get some service like object (e.g. some AuthService) you may register it as a service (you may have already done since you call getAuthService() on the controller) and use the ServiceLocator to get it or – even better for unit testing – inject it via a factory to your controller. You may want to take a look at ZfcUser to see how it’s done.

    If you – for some reason – insist on using this hard-coded approach (which is really working against the framework) I think you just setup autoloading incorrectly or the ZfCommons module is not activated.

    First

    Check your application.config.php for activated modules. ZfCommons and Application need to be activated at least.

    Second

    Check ZfCommons’ Module.php for initializing of the autoloader:

    <?php
    namespace ZfCommons;
    
    use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
    use Zend\Loader\StandardAutoloader;
    
    class Module implements AutoloaderProviderInterface,
    {
        // snip
    
        /**
         * {@inheritDoc}
         */
        public function getAutoloaderConfig()
        {
            return array(
                'Zend\Loader\StandardAutoloader' => array(
                    'namespaces' => array(
                        __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                    ),
                ),
            );
        }
    
        // snip
    }
    

    This will initialize class autoloading for the namespace ZfCommons.

    If your filenames map correctly to classes and interfaces according to PSR-0 it should work now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to instantiate a class within a class, so that the outer class
Hello trying to get my binding to work over internet. im using wsHttpBinding and
Hello im trying to wrap a div with another div by using jquery append
Hello I am trying to call a method (fileReader) that is using openFileInput(filename) from
Hello Trying to sort this list by Month and day. Can not get it
Hello trying to get my website to display correctly having trouble. I am using
Hello im trying to use random integer range and the values that i get
Hello im trying to echo only the 50 letters, but something in my code
hello i am trying a sqlite database tutorial to build, but its not working
Hello I was trying to remove objects from object array that I have and

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.