Use a Different Database Library
Hopper is the bundled default — but the framework doesn't depend on it for anything outside $App->db. Drop in Doctrine DBAL, Eloquent, raw PDO, or whatever fits your project.
The contract
There isn't one. $App->db is just a property on the application object. The framework never calls $App->db itself — only your controllers do — so you decide what type of object lives there.
Replace it in init.php
Wherever the bootstrap currently does this:
$App->db = new \Truecast\Hopper((array) $App->config->mysql);
Swap in the wrapper of your choice. A few examples:
Raw PDO
$cfg = $App->config->mysql;
$dsn = "mysql:host={$cfg->host};dbname={$cfg->database};charset=utf8mb4";
$App->db = new \PDO($dsn, $cfg->username, $cfg->password, [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ,
]);
Doctrine DBAL
use Doctrine\DBAL\DriverManager;
$App->db = DriverManager::getConnection([
'driver' => 'pdo_mysql',
'host' => $App->config->mysql->host,
'user' => $App->config->mysql->username,
'password' => $App->config->mysql->password,
'dbname' => $App->config->mysql->database,
]);
Eloquent (Capsule)
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'mysql',
'host' => $App->config->mysql->host,
'database' => $App->config->mysql->database,
'username' => $App->config->mysql->username,
'password' => $App->config->mysql->password,
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$App->db = $capsule;
Mixing libraries
Nothing stops you from keeping Hopper for one piece of code while using a heavier library elsewhere. A common split:
- Hopper for read-heavy admin pages where its
get($sql, $params, 'objects')shorthand keeps things terse. - Doctrine or Eloquent for the parts of the domain model where you want migrations, relations, or query-builder ergonomics.
Add a second property in init.php and use whichever name reads best at the call site:
$App->db = new \Truecast\Hopper(/* ... */); // legacy / admin
$App->orm = $entityManager; // Doctrine
Removing Hopper entirely
If you're not using it, you can drop the dependency from composer.json:
composer remove truecastdesign/hopper
Nothing in true or welder imports it directly, so the rest of the framework keeps working.