davedevelopment / phpmig

Simple migrations system for php
Other
569 stars 92 forks source link

Ability to set Container in Console Mode #134

Closed aneek closed 6 years ago

aneek commented 6 years ago

Hello,

I have been using your library for quite a long time and recently I came up with a requirement to remove the 'phpmig.php' file in one of my project. Instead, the application would define the container. Is there any way to supply container inside the commands?

I don't want to use Phpmig\Api\PhpmigApplication class. The code is:

#!/usr/bin/env php
<?php
require_once 'vendor/autoload.php';

use Symfony\Component\Console;

$cli = new Console\Application('API Console', '1.x');
$cli->setCatchExceptions(true);

// Add Migrations commands
$commands = array();
$commands[] = new Phpmig\Console\Command\UpCommand();
$commands[] = new Phpmig\Console\Command\StatusCommand();

// add migrate name space for migrations.
foreach ($commands as $command) {
    $command->setName('migrate:' . $command->getName());
}
$cli->addCommands($commands);

// Run!
$cli->run();

When I am calling php bin/console migrate:status this shows the below error:

In FileLocator.php line 71:

  The file "phpmig.php" does not exist (in: D:\wamp\elfin\config, D:\wamp\elf
  in).

migrations:status [-s|--set SET] [-b|--bootstrap BOOTSTRAP]

Regards, Aneek

davedevelopment commented 6 years ago

Hi @aneek

Right now, that's not possible, but I think it should be. I don't have much time to work on new features like this, but I would be happy to accept a PR that does this, providing it doesn't break the existing functionality. I'd prefer phpmig to continue working as a standalone app.

aneek commented 6 years ago

@davedevelopment thanks for your input. I might fork and work on this sometime soon. It's evident that this is not an issue but a feature request. So closing this one for now.

Regards, Aneek