Zend Framework 2 Override an existing service?

I am using a zf2 module called GoalioRememberMe, and now I want to redefine its service with my personalized service. Or, if this is not possible, I want to override Module.php with my configuration. Is it possible?

In the application module. I wrote this line in module.config.php file:
'GoalioRememberMe\Service\RememberMe' => 'Application\Service\RememberMe'

Thanks in advance!

+4
source share
3 answers

For this reason, it is recommended that you specify the service as the type of the returned object. The object GoalioRememberMe\Service\RememberMeis called goaliorememberme_rememberme_servicein the service manager. You can check that out here .

So the solution is simple, not the following:

'GoalioRememberMe\Service\RememberMe' => 'Application\Service\RememberMe'

Write it down

'goaliorememberme_rememberme_service' => 'Application\Service\RememberMe'
+5

, goaliorememberme_rememberme_service, getServiceConfig(). Module.php Application Module:

$serviceManager->
            setAllowOverride(true)->
            setInvokableClass('goaliorememberme_rememberme_service', 'Application\Service\CustomRememberMe')->
            setAllowOverride(false);

!
!

+1

"canonicalizeName()", "" :

  • _/\ -

, "GoalioRememberMe\Service\RememberMe", "goaliorememberme_rememberme_service" "goalioremembermeremembermeservice" (.. ), .

The quickest way to override an existing service is to create a * local.php or * global.php file in the / config / autoload folder. (This folder is identified in config / application.config.php.) Any override files in this folder are executed after loading the modules. If you have duplicate service manager keys, the latter wins.

0
source

All Articles