cphalcon
cphalcon copied to clipboard
DI::setParameter doesn't exists
http://docs.phalconphp.com/en/0.7.0/reference/di.html Documentation telling I can use method \Phalcon\DI\FactoryDefault::setParameter, but it doesn't exists
var_dump(method_exists('\Phalcon\DI\FactoryDefault', 'setParameter'));
// false
Also doesn't works
//Register a service "db" with a class name and its parameters
$di->set("db", array(
"className" => "Phalcon\Db\Adapter\Pdo\Mysql",
"parameters" => array(
"parameter" => array(
"host" => "localhost",
"username" => "root",
"password" => "secret",
"dbname" => "blog"
)
)
));
// Warning: Phalcon\Db\Adapter\Pdo::__construct() expects exactly 1 parameter, 0 given
Hi! You marked this issue as a bug. Does it means this is the docs bug, or setParameter is deprecated?
Heya, this method must be there, but it looks it was removed by mistake :(
This is now fixed, the correct syntax is:
<?php
$di->set('db', array(
'className' => 'Phalcon\Db\Adapter\Pdo\Mysql',
'arguments' => array(
array(
'type' => 'parameter',
'value' => array(
"host" => "localhost",
"username" => "root",
"password" => "secret",
"dbname" => "blog"
)
)
)
));