diff --git a/src/Composer/Command/DebugPackagesCommand.php b/src/Composer/Command/DebugPackagesCommand.php new file mode 100644 index 000000000..b92d06373 --- /dev/null +++ b/src/Composer/Command/DebugPackagesCommand.php @@ -0,0 +1,62 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Command; + +use Composer\Autoload\AutoloadGenerator; +use Composer\DependencyResolver; +use Composer\DependencyResolver\Pool; +use Composer\DependencyResolver\Request; +use Composer\DependencyResolver\Operation; +use Composer\Package\LinkConstraint\VersionConstraint; +use Composer\Repository\PlatformRepository; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @author Jordi Boggiano + */ +class DebugPackagesCommand extends Command +{ + protected function configure() + { + $this + ->setName('debug:packages') + ->setDescription('Lists all existing packages and their version') + ->setHelp(<<php composer debug:packages + +EOT + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $composer = $this->getComposer(); + + // create local repo, this contains all packages that are installed in the local project + $localRepo = $composer->getRepositoryManager()->getLocalRepository(); + // create installed repo, this contains all local packages + platform packages (php & extensions) + $installedRepo = new PlatformRepository($localRepo); + + foreach ($installedRepo->getPackages() as $package) { + $output->writeln('installed: '.$package->getName().' '.$package->getVersion()); + } + + foreach ($composer->getRepositoryManager()->getRepositories() as $repository) { + foreach ($repository->getPackages() as $package) { + $output->writeln('available: '.$package->getName().' '.$package->getVersion()); + } + } + } +} diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 5730add3e..1f0f12e8a 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -16,7 +16,7 @@ use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; -use Composer\Command\InstallCommand; +use Composer\Command; use Composer\Composer; /** @@ -63,6 +63,7 @@ class Application extends BaseApplication */ protected function registerCommands() { - $this->add(new InstallCommand()); + $this->add(new Command\InstallCommand()); + $this->add(new Command\DebugPackagesCommand()); } }