= new MySqlDB('localhost', 'root', '', 'test'); } // You can configure it with an array public function __construct($config) { $this->_db = new MySqlDB($config['host'], $config['user'], $config['pass'], $config['db']); } // And, What we saw earlier public function __construct() { $this->_db = new MySqlDB(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB); } Options
new MySqlDB('localhost', 'root', '', 'test'); } $c->user = function ($c) { $db = $c->mysql; return new User($db); } // When you need a user $user = $c->user; // Instead of $user = new User(); Container