New Class based configuration and di->set

13 views
Skip to first unread message

guillaume ferrand

unread,
Apr 8, 2014, 8:58:53 AM4/8/14
to aur...@googlegroups.com
Hello,

I'm experiencing a problem since the BC break.
I have followed the migration plan and almost everything works fine : routes are ok, controllers are found, etc but i have a problem with my Database connection.

It ends in an exception since my object is empty:
#0 /var/www/api_authentification/vendor/aura/sql/src/ExtendedPdo.php(236): PDO->__construct('', NULL, NULL, Array)

My application and database connection used to work perfectly before the new class based config file, so I know that there is something with the new config system

I have this in my Common::define config class :

// set params for Mbrevda\Queryproxy\Db constructor which inherits from PDO
$di->params['Mbrevda\Queryproxy\Db'] = array (
            'dsn' => 'pgsql:host=192.168.1.80;dbname=flinteractive;port=5434',
            'username' => 'YYY',
            'password' => 'XXX',
            'options' => array(), // driver options as key-value pairs
            'attributes' => array()  // attributes as key-value pairs
        );
 
$di->set('db_connection', $di->lazyNew('Mbrevda\Queryproxy\Db'));

// set params for the Thedigital\Model_Template\AbstractModel class
$di->params['Thedigital\Model_Template\AbstractModel'] = [
       'db_connection' => $di->lazyGet('db_connection'),
];


My problem : 
the $db_connection parameter in my Thedigital\Model_Template\AbstractModel object is an empty Mbrevda\Queryproxy\Db object for some reason I can't find out.

In Thedigital\Model_Template\AbstractModel :

public function __construct(Db $db_connection)
{
        var_dump($db_connection);
        $this->db_connection = $db_connection;

        $this->column_factory = new ColumnFactory();
        $this->schema_described = new PgsqlSchema($this->db_connection, $this->column_factory);
}

the var_dump outputs :
object(Mbrevda\Queryproxy\Db)#322 (8) { ["pdo":protected]=> NULL ["attributes":protected]=> array(2) { [3]=> int(2) [20]=> bool(true) } ["dsn":protected]=> NULL ["options":protected]=> array(0) { } ["password":protected]=> NULL ["profile":protected]=> array(0) { } ["profiler":protected]=> NULL ["username":protected]=> NULL } 


Did I miss something in my Common.php config file ?

What's the strangest is that the others $di->set or $di->params are correctly filled / set

Advices or hints would be greatly appreciated :D

Paul M. Jones

unread,
Apr 8, 2014, 10:07:27 AM4/8/14
to aur...@googlegroups.com

On Apr 8, 2014, at 7:58 AM, guillaume ferrand <guillaum...@gmail.com> wrote:

> Hello,
>
> I'm experiencing a problem since the BC break.
> I have followed the migration plan and almost everything works fine : routes are ok, controllers are found, etc but i have a problem with my Database connection.

Oh oh oh. I think it's a problem with the (newly stable) Aura.Sql. Short version: we moved the constructor parameters out of the constructor so it could become pseudo-polymorphic, and now the DI container does not know how to match up the named parameters. I will address this within the next hour. My apologies for the hassle.


--
Paul M. Jones
pmjo...@gmail.com
http://paul-m-jones.com

Modernizing Legacy Applications in PHP
http://mlaphp.com



Paul M. Jones

unread,
Apr 8, 2014, 10:19:46 AM4/8/14
to aur...@googlegroups.com

On Apr 8, 2014, at 9:07 AM, Paul M. Jones <pmjo...@gmail.com> wrote:

>
> On Apr 8, 2014, at 7:58 AM, guillaume ferrand <guillaum...@gmail.com> wrote:
>
>> Hello,
>>
>> I'm experiencing a problem since the BC break.
>> I have followed the migration plan and almost everything works fine : routes are ok, controllers are found, etc but i have a problem with my Database connection.
>
> Oh oh oh. I think it's a problem with the (newly stable) Aura.Sql. Short version: we moved the constructor parameters out of the constructor so it could become pseudo-polymorphic, and now the DI container does not know how to match up the named parameters. I will address this within the next hour. My apologies for the hassle.

All right, I have released Aura.Sql 2.0.1 with the parameters moved back to the constructor. Update via Composer and let me know if it works or not.

guillaume ferrand

unread,
Apr 8, 2014, 11:38:22 AM4/8/14
to aur...@googlegroups.com
It works perfectly now ! Fast and efficient as always ;)

Thanks a lot
Reply all
Reply to author
Forward
0 new messages