composer/composer — pull request #2995 by BreiteSeite (2014-05-16 20:42:57+00:00)
Title: predictable autoload.php location

Hi there,

when writing composer packages with binary files, one thing bugs me: the location of the autoload.php-to-include differs with context.
If i write my package, i can happily include "vendor/autoload.php" and it works as long as i'm in my only-package context... but when the package get installed because of a requirement, the installed package must search the autoload.php because it's suddenly above the package content. This has 3 major drawbacks:
* It leads to duplicated code because nearly every package with binaries includes similar functionality searching the autoload.php ([composer](https://github.com/composer/composer/blob/master/src/bootstrap.php#L18), [doctrine](https://github.com/doctrine/doctrine2/blob/master/bin/doctrine.php#L23), ...)
* Performance is not optimal because packages have to search through the filesystem
* Error prone because some implementations may rely on the fact that there is a autoload.php somewhere above them and therefor create an endless recursion when this isn't the case.

This PR changes the proposes the following change after the execution of composer install
```
- (root package contents)
- /vendor
- autoload.php
- bin
- some_binary.php -> /vendor/FooVendor/BarPackage/bin/some_binary.php
- FooVendor
- BarPackage
- bin
- some_binary.php
- vendor (NEW!)
- autoload.php -> /vendor/autoload.php (NEW!)
(and so on)
```

This way binaries of vendor packages can just `require realpath(__DIR__) . '/vendor/autoload.php';` and it works in every context.

Feedback and opinions are very welcome.

Thank you.