Last active
November 24, 2015 22:41
-
-
Save dadamssg/5d89a29ee4c596c678a9 to your computer and use it in GitHub Desktop.
Incorporating a symfony console into a silex application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php // app/cli.php | |
use Silex\Application; | |
use Symfony\Component\Console\Application as Console; | |
require __DIR__ . '/../vendor/autoload.php'; | |
/** @var Application $app */ | |
$app = require 'app.php'; | |
$console = new Console(); | |
// requires $app['db'] to return a dbal connection | |
$app->register( | |
new \Kurl\Silex\Provider\DoctrineMigrationsProvider($console), | |
[ | |
'migrations.directory' => __DIR__ . '/../config/migrations', | |
'migrations.name' => 'Acme Migrations', | |
'migrations.namespace' => 'Acme\Migrations', | |
'migrations.table_name' => 'acme_migrations', | |
] | |
); | |
$console->add(new \Acme\Console\ResetUserPassword($app)); | |
$app->boot(); | |
$console->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure you make the file executable:
chmod +x app/cli.php
And use it:
php app/cli.php migrations:generate