I am new to Symfony 2 and trying to create a simple application to learn. I created a package GoogleApiBundle. Inside the bundle, I have a controller YouTubeControllerthat is a service:
service:
myname_googleapi_youtube:
class: Myname\GoogleApiBundle\Controller\YouTubeController
In another package, I'm trying to call a function in YouTubeController
$service = $this->get('myname_googleapi_youtube');
$result = $service->getResultFunction();
public function getResultFunction()
{
$parameter = $this->container->getParameter('a');
}
Then I get an exception FatalErrorException: Error: Call to a member function getParameter() on a non-object ...because there $this->containeris NULL.
I searched but received no answer. Am I doing wrong?
source
share