How can I pass a PDO object to an Illuminate Capsule Manager

246 views Asked by At

I'm using Cartalyst's Sentinel user package as part of a user login library w/ a gui that I'm making. Sentinel uses Illuminate for the database.
So to set up the connection I have to do something like:

        $capsule = new \Illuminate\Database\Capsule\Manager;
        $capsule->addConnection($dbInfo = [
            'driver'    => $package->get('DB.driver'),
            'host'      => $package->get('DB.host'),
            'charset'   => $package->get('DB.charset'),
            'collation' => $package->get('DB.collation'),
            
            'database'  => $package->get('DB.database'),
            'username'  => $package->get('DB.user'),
            'password'  => $package->get('DB.password'),
        ]);
        $capsule->bootEloquent()

Where $package is my own thing & is pretty self explanator. Just returns values for keys here.

Instead of using $capsule->addConnection($arrayOfLoginInfo), I'd like to pass a previously instantiated PDO object. Something like:

$pdo = new \PDO($dsn, $username, $password);
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addPdoConnection($pdo);
$capsule->bootEloquent()

But the capsule manager does not appear to have such a method.

I've never used Illuminate before, but I did some research a couple weeks ago & wasn't able to find a solution.

0

There are 0 answers