问题描述:

I am new to symfony2.

I am trying to instantiate a service throug the container.

app/config/config.yml:

services:

mci.service_registry:

class: Mci\APIBundle\MciServiceRegistry

mci.service_listener:

class: Mci\APIBundle\EventListener\MciServiceListener

tags:

- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }

calls:

- [setRegistry, ["@mci.service_registry"]]

MciServiceListener:

namespace Mci\APIBundle\EventListener;

class MciServiceListener

{

public function __construct()

{

echo "CONSTRUCTING SERVICE LISTENER\n";

}

}

Shouldn't I see the log output?

To me it seems as the service is not being instantiated.

When I do php app/console container:debug | grep mci I get:

mci.service_listener container Mci\APIBundle\EventListener\MciServiceListener

mci.service_registry container Mci\APIBundle\MciServiceRegistry

网友答案:

Sorry, my bad,

there was a huuuuge typo in the php file (it was not starting with

相关阅读:
Top