I like the plugin, but you may want to instantiate a PDO instance inside the plugin instead of directly extending PDO. The reason is that it should be in a try/catch block, because PDO reveals connection details if if cannot connect as part of the default exception message printing in PHP.
$k->addMethod('db', array($this, 'pdoInstance'));
}
public function pdoInstance() {
if(!$this->_pdo) {
$dbcfg = $k->config('database.master');
// DSN String
$dsn = $dbcfg['adapter'] . ':dbname=' . $dbcfg['database'] . ';host=' . $dbcfg['host'];
// Use try/catch so credentials will never be revealed
try {
$this->_pdo = new \PDO($dsn, $dbcfg['username'], $dbcfg['password'], $dbcfg['options']);
} catch(\PDOException $e) {
throw new \Exception("Unable to connect to database: " . $e->getMessage());
}
}
return $this->_pdo;
}
}