1
0
Fork 0

Allow Composer to be used without running the application

For [Humbug
Box](https://github.com/humbug/box/blob/master/src/Composer/ComposerOrchestrator.php#L30) we are
using Composer to dump the autoload. To do so I'm using the `Composer` class from the application:

```php
$composer = (new ComposerApplication())->getComposer();
```

If you do so however this is going to fail because `Application#io` is null instead of being a
`IOInterface` instance. Indeed it is initialised only when the application is run. So one solution
is to initialised it with a dummy IO and the right IO object will be set when the application is run
as usual.
pull/7212/head
Théo FIDRY 2018-03-24 07:32:04 +00:00
parent 4d8b9be5b6
commit b7ab081519
No known key found for this signature in database
GPG Key ID: F8C66BC24296DE7E
1 changed files with 3 additions and 0 deletions

View File

@ -12,6 +12,7 @@
namespace Composer\Console;
use Composer\IO\NullIO;
use Composer\Util\Platform;
use Composer\Util\Silencer;
use Symfony\Component\Console\Application as BaseApplication;
@ -85,6 +86,8 @@ class Application extends BaseApplication
});
}
$this->io = new NullIO();
parent::__construct('Composer', Composer::VERSION);
}