I have the following service :
<?php
namespace App\Services;
use ADOConnection;
class ADOdbConnection
{
/**
* AdodbConnection constructor.
* @param $host
* @param $user
* @param $pwd
* @param $db
*/
public function __construct($host, $user, $pwd, $db_name)
{
$db = ADONewConnection('odbc');
$db->connect($host, $user, $pwd, $db_name);
}
/**
* Testing current connection
* @return mixed
*/
public function testConnection()
{
return $this->db->IsConnected();
}
}
Very simple, and the pending configuration into config/services.yaml :
// config/services.yaml
services:
//... -- 15 lines -- //
App\Services\ADOdbConnection:
arguments:
$host: '111.11.11.11'
$user: 'ROOT'
$pwd: '%env(resolve:DATABASE_W2_PASSWORD)%'
$db_name: 'CUSTOMER'
(See full config/services.yaml)
In my controller i got this :
public function index(ADOdbConnection $ADOdbConnection)
{
dump($ADOdbConnection->testConnection());
}
And the result is this error :
Cannot resolve argument $ADOdbConnection of "App\Controller\ArticleController::index()": Cannot autowire service "App\Services\ADOdbConnection": argument "$host" of method "__construct()" has no type-hint, you should configure its value explicitly.
I have read this doc :
And this one :
I do the same thing as explain in the symfonycast formation, but i can't get it why it is not working...
I have also read this :
But i'm not interested in this feature at the moment.
EDIT :
I just figure that i need to define the arguments configuration into my config/services_dev.yaml
but to me this is a weird since kernel read the file in order
- config/services.yaml
- then config/services_XXX.yaml
So i should not need to define those parameter a second time.