Skip to content

Instantly share code, notes, and snippets.

@davehewy
Created February 24, 2015 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davehewy/abf924b859e4d46247dd to your computer and use it in GitHub Desktop.
Save davehewy/abf924b859e4d46247dd to your computer and use it in GitHub Desktop.
Eloquent and PHPmig (note this does not work)
dave:~/sites/bin $ ./phpmig status
PHP Fatal error: Call to a member function schema() on boolean in /Users/davidheward/sites/vendor/davedevelopment/phpmig/src/Phpmig/Adapter/Illuminate/Database.php on line 89
Fatal error: Call to a member function schema() on boolean in /Users/davidheward/sites/vendor/davedevelopment/phpmig/src/Phpmig/Adapter/Illuminate/Database.php on line 89
<?php
require '../game/http/includes/config.php';
use \Phpmig\Pimple\Pimple,
\Phpmig\Adapter,
\Illuminate\Database\Capsule\Manager as Capsule;
$container = new Pimple();
$container['config'] = array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'migration_test',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
);
$container['db'] = $container->share(function($c) {
$dbh = new PDO("mysql:host=" . $c['config']['host'] . ";dbname=" . $c['config']['database'], $c['config']['username'], $c['config']['password']);
$dbh = $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbh;
});
$container['schema'] = $container->share(function($c) {
$capsule = new Capsule;
$capsule->addConnection($c['config']);
$capsule->setAsGlobal();
return Capsule::schema();
});
// $container['phpmig.adapter'] = $container->share(function($c){
// return new PDO($c['db'], 'migrations');
// });
$container['phpmig.adapter'] = $container->share(function() use ($container) {
return new \Phpmig\Adapter\Illuminate\Database($container['db'], 'migrations');
});
$container['phpmig.migrations_path'] = __DIR__ . DIRECTORY_SEPARATOR . 'migrations/';
return $container;
@silentworks
Copy link

What version of Eloquent you using? This was written and tested with version 4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment