Kdyby / Console

Symfony Console integration for Kdyby components
https://packagist.org/packages/kdyby/console
Other
52 stars 54 forks source link

Drop dependency on Nette\Application #30

Closed JanTvrdik closed 8 years ago

JanTvrdik commented 9 years ago

I don't understand why does console need to depend on Nette\Application so I'd like to propose to relax this dependency.

To make it a bit clearer. I'd like to do this:

$dic = require __DIR__ . '/../app/bootstrap.php';
$app = $dic->getByType(Kdyby\Console\Application::class);
$app->run();
enumag commented 9 years ago

:+1: I also use Kdyby\Console\Application directly. For links generation in commands it's better to use nextras/link-factory.

fprochazka commented 9 years ago

You should be able to do the thing that you're suggesting right now, it should work without any problems.

But, the dependency is there for two reasons...

1) simplicity - you install the extension run php www/index.php and it just works™ 2) "fixed" links generation

The second one is not relevant in Nette 2.3, so this could be refactored a bit. It also might be made optional.

JanTvrdik commented 9 years ago

it should work without any problems.

It does not work because ConsoleExtension assumes that services such as application do exist. The simple solution may be to use hasDefinition before getDefinition. Another example – this should work:

$loader = new ContainerLoader($tempDirectory, TRUE);
$className = $loader->load('', function (Compiler  $compiler) {
    $compiler->addExtension('console', new Kdyby\Console\DI\ConsoleExtension());
});

$dic = new $className;
$app = $dic->getByType(Kdyby\Console\Application::class);
$app->run();

But, the dependency is there for two reasons...

I understand why there is the dependency, but not why it is a required dependency. Optional dependency is fine.

fprochazka commented 9 years ago

I wasn't expecting you'd actually have a project with only few nette packages. I'm on board with that. Making it optional makes sense :)

TomasVotruba commented 9 years ago

:+1:

vojtech-dobes commented 9 years ago

:+1: