composer/composer — pull request #1863 by simensen (2013-05-03 20:18:46+00:00)
Title: Add root package to installed.json

Use case is embedding composer. It is extremely useful to know the package information for the package that has has embedded Composer.

The root package will be added to the local repository (installed.json) as the final step of the installation process.

Special handling was required to ensure that the root package did not ever end up in the lock. Packages matching the root package name will be filtered from both the required and dev required package lists.

The installer fixtures were updated to account for `--EXPECT-INSTALLED--` similar to how the lock file handling is currently handled.

The mock installed filesystem repository was updated to allow the write method to pass thru.

Two of the simpler tests, one for install, one for update, were updated to account for the new installed behavior.

All tests pass.

---

For some additional context, I'm working with this for my [Embedded Composer](https://github.com/dflydev/dflydev-embedded-composer) project and currently have the following hacky workaround to make things kinda work:

```php
getParameterOption('--project-dir') ?: '.';

// This package should accurately represent the package that contains
// the application being run.
$package = new Package('my/app', '2.0.5', '2.0.5');

$embeddedComposer = new EmbeddedComposer(
$classLoader,
$projectDir,
$package
);

$embeddedComposer->processExternalAutoloads();

// Composer is now ready to load local packages as well as the packages
// that make up the calling application.
```

I'd like to be able to change this to something more like:

```php