Skip to content

Instantly share code, notes, and snippets.

@rianorie
Created December 5, 2014 15:05
Show Gist options
  • Save rianorie/40e241aa74390309d764 to your computer and use it in GitHub Desktop.
Save rianorie/40e241aa74390309d764 to your computer and use it in GitHub Desktop.
<?php
class MyLib extends \Phalcon\Di\InjectionAware
{
private $filename;
public function __construct(\Phalcon\DiInterface $di)
{
$this->setDI($di);
$this->filename = $this->getDI()->get('config')->daemon->hb_filename;
}
}
// ------------------------
$di->set('mylib', function() use ($di) {
return new MyLib($di);
});
// ------------
$di->getShared('mylib'); // shared version of the class, for all intents and purposes a singleton.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment