Implementing ContainerAwareInterface like shown in other posts is better way of doing things.


FeatureContext.php


namespace Football\TeamBundle\Features\Context;

use Behat\MinkExtension\Context\MinkContext;
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Symfony\Component\HttpKernel\KernelInterface;

class FeatureContext extends MinkContext implements KernelAwareInterface
{
private $kernel;

public function setKernel(KernelInterface $kernelInterface)
{
$this->kernel = $kernelInterface;
}

public function getParameter()
{
$myParameter = $this->kernel->getContainer()->getParameter('name_of_the_param');
}

public function getService()
{
$myService = $this->kernel->getContainer()->get('name_of_the_service');
}

public function iFindCountryInDatabase($name)
{
$em = $this->kernel->getContainer()->get('doctrine')->getManager();
$repo = $em->getRepository('FootballTeamBundle:Country');
$country = $repo->findOneBy(array('name' => $name));
}
}