Instantiate a class in app/libraries and pass the database connection to the instance

Hello,

I am a Phalcon 3.3.1 newbie.

I have not found any docs relating to instantiate a class in app/libraries and passing the database connection to the instance.

How can I instantiate a class in app/libraries and pass the database connection to the instance?



78.8k

after you register db connection as a service , from the tutorials


//controller
$this->getDI()->get("DB");

//static
$db = \Phalcon\Di::getDefault()->get("DB")