Skip to content

Instantly share code, notes, and snippets.

@vkbansal
Created March 12, 2015 12:31
Show Gist options
  • Select an option

  • Save vkbansal/6e7b1ef60a9c161cd3dc to your computer and use it in GitHub Desktop.

Select an option

Save vkbansal/6e7b1ef60a9c161cd3dc to your computer and use it in GitHub Desktop.

Revisions

  1. vkbansal created this gist Mar 12, 2015.
    48 changes: 48 additions & 0 deletions artisan.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    <?php
    require_once "vendor/autoload.php";

    use Symfony\Component\Console\Application;
    use Illuminate\Database\Console\Migrations;
    use Pimple\Container;

    $container = new Container();

    $container['migration-table'] = 'migration';

    $container['db-config'] = [
    'driver' => 'pgsql',
    'host' => 'localhost',
    'database' => 'dummy',
    'username' => 'postgres',
    'password' => 'root',
    'charset' => 'utf8',
    'prefix' => '',
    'schema' => 'public'
    ];

    $container['filesytem'] = function ($c) {
    return new \Illuminate\Filesystem\Filesystem;
    };

    $container['connection'] = function ($c) {
    $manager = new \Illuminate\Database\Capsule\Manager();
    $manager->addConnection($c['db-config']);
    $manager->setAsGlobal();
    $manager->bootEloquent();
    return $manager->getConnection('default');
    };

    $container['resolver'] = function ($c) {
    $r = new \Illuminate\Database\ConnectionResolver(['default' => $c['connection']]);
    $r->setDefaultConnection('default');
    return $r;
    };

    $container['migration-repo'] = function ($c) {
    return new \Illuminate\Database\Migrations\DatabaseMigrationRepository($c['resolver'], $c['migration-table']);
    };

    $app = new Application("Foo", "1.0");
    $app->add(new Migrations\InstallCommand($container['migration-repo']));

    $app->run();