You should implement this using ``filterPackages`` to be more memory efficient. You can find an usage example [here](https://github.com/composer/composer/blob/master/src/Composer/Command/InitCommand.php#L289)