KnpLabs/ConsoleServiceProvider

Console application boots Silex application

sokil opened this issue · 4 comments

sokil commented

ConsoleServiceProvider must be registered last, because it boots silex application providers.

I want to use \Kurl\Silex\Provider\DoctrineMigrationsProvider for migrations. This provider require Console application, so i add it:

<?php
$app->register(new ConsoleServiceProvider(), array(
    'console.name'              => 'app',
    'console.version'           => '1.0.0',
    'console.project_directory' => __DIR__
));

// at this moment all previders registered in silex app are booted

$app->register(
    new \Kurl\Silex\Provider\DoctrineMigrationsProvider($app['console']),
    array(
        'migrations.directory'  => __DIR__ . '/../migrations',
        'migrations.name'       => 'app',
        'migrations.namespace'  => 'App\Migrations',
        'migrations.table_name' => 'migrations',
    )
);

// at this moment to late to register anything. Application already booted

+1 came here to report this too!
What's the status?

Fix merged in #32.

People who depend on the old behavior can set the new console.boot_in_constructor parameter to true.