Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Last active November 24, 2015 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadamssg/5d89a29ee4c596c678a9 to your computer and use it in GitHub Desktop.
Save dadamssg/5d89a29ee4c596c678a9 to your computer and use it in GitHub Desktop.
Incorporating a symfony console into a silex application.
#!/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();
@dadamssg
Copy link
Author

Make sure you make the file executable:

chmod +x app/cli.php

And use it:

php app/cli.php migrations:generate

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