$loader = new Phalcon\Loader();
$loader->registerNamespaces(array(
'My\\Controller'=>'../Application/My/Controller',
'My\\Model\\Object'=>'../Application/My/Model/Object'
))->register();
$config = new \Phalcon\Config\Adapter\Ini('../Application/My/Config/config.ini');
$di = new \Phalcon\DI\FactoryDefault();
$di->set('db', function() use ($config) {
return new \Phalcon\Db\Adapter\Pdo\Mysql($config->Database->toArray());
}, true);
$myModel = \My\Model\Object\MyModel::findFirst();
Just starting out with Phalcon. In the above code I can succesfully get the first of my model objects from the database set within the DI container. But how does the static model call even know of the DI container I have instantiated? This seems to go against the very concept of dependency injection.