Search code examples
phpcomposer-phpautoloader

Composer, the Autoloader, and VCS


With regard to the contents of the VENDOR directory, the FAQs for Composer (and elsewhere in the documentation) state that:

The vendor directory (or wherever your dependencies are installed) should be added to .gitignore/svn:ignore/etc.

I am introducing Composer and PHPUnit dependencies into a project that does not adhere to any PSR standard, so it looks like I need to start with a class map.

While it's pretty clear to me to ignore the VENDOR dir, it is not clear to me whether the autoload.php file should be excluded also.

In some experimenting I've done with Composer and PHPUnit, I have not gotten any of my tests running without using the autoload.php as a bootstrap file for PHPUnit, and I am certain that other code throughout this admittedly messy project will use it. So it makes sense to me that I need to keep it, but I have no idea where to put it.

So do I have this correct? If I include the autoload.php file in VCS in order to use it elsewhere, do I need to move it? If so, where, if I'm looking at this with PSR compliance in mind?

I am primarily a .NET developer, please be gentle.

Thanks.


Solution

  • While it's pretty clear to me to ignore the VENDOR dir, it is not clear to me whether the autoload.php file should be excluded also.

    Composer's autoload.php file should indeed be ignored, as it's part of the vendor directory. It's automatically generated as part of the composer install / composer update process.