I am learning Symfony2 and trying to Connect to doctrine dbal. But i am encountering an error which up to this point i cannot solve.
Error message:
Catchable fatal error: Argument 1 passed to Doctrine\DBAL\Connection::__construct() must be of the type array, none given, called in /Users/toma/Dev/api/app/cache/dev/appDevDebugProjectContainer.php on line 2313 and defined in /Users/tom/Dev/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php on line 192
This is where I am calling the Doctrine/DBAL/Connection:
<?php
namespace API\Test\TestDoctrine\Repository;
use API\TestBundle\TestDoctrine\DatabaseRepository;
use Doctrine\DBAL\Connection;
use Psr\Log\LoggerInterface;
class TestRepo {
public $doctrine;
public function __construct(
DatabaseRepository $databaseRepository,
Connection $connection,
LoggerInterface $logger
){
$this->doctrine = $databaseRepository;
}
public function test()
{
$test = 'Hey';
return $test;
}
}
I have creted this file as a service and injecting it into my repository where i want to query my DB. I tried google this issue but unfortinally cannot find an answer.
Services.xml
<service id="api.dto.template.connection"
class="Doctrine\DBAL\Connection">
</service>
<service id="api.dto.template.logger"
class="Psr\Log\LoggerInterface">
</service>
<service id="api.testdoctrine.database_repository"
class="Api\TestBundle\TestDoctrine\DatabaseRepository">
<argument type="service" id="japi.dto.template.connection" />
<argument type="service" id="api.dto.template.logger" />
</service>
<service id="api.testdoctrine.repository.test_repo"
class="API\TestBundle\TestDoctrine\Repository\TestRepo">
<argument type="service" id="api.testdoctrine.database_repository" />
</service>