Skip creating startup files in composer?

So, I have a simple PCR0 autoloader in my bootstrap.php that should load any PCR0 compatible library class from the vendors directory ...

spl_autoload_register( function( $classname ) { $path = preg_match( '/\\\\/', $classname ) ? str_replace( '\\', DIRECTORY_SEPARATOR, $classname ) : str_replace( '_', DIRECTORY_SEPARATOR, $classname ); $file = VENDORS_PATH . DIRECTORY_SEPARATOR . $path . '.php'; if ( file_exists( $file ) ) { require_once( $file ); } }); 

I am not sure if I understand why the composer creates automatic download files in the suppliers directory (namely the composer and autoload.php file)?

Can I stop the linker from creating these startup files? or am I missing something? I don’t think I need them?

+7
source share
3 answers

There are three startup files related, each with a different purpose.

  • vendor / autoload.php initializes composer autoloaders. Composer offers autoloaders to download composer-compatible libraries.
  • vendor / composer / autoload_classmap.php This file is used by the classmap autoloader, this is for libraries that are not compatible with PSR-0 or production environments (classmap is faster than searching through the file system).
  • vendor / composer / autoload_namespaces.php is the configuration for PSR-0 startup, which includes

Now you have mentioned that you have your own PSR-0 class loader, which you should not use for compiler dependencies - you just have to require / enable the /autoload.php provider, and the composer will take care of the rest.

This is why there is no way to disable startup file generation. In the end, the composer should allow you to use the installed library and allow you, providing all the work you need.

+4
source

Unfortunately, it doesn't seem like Composer will support this feature: https://github.com/composer/composer/issues/1663

0
source

Personally, I added these files to .gitignore, since the project I'm working on has an autoloader that works great

0
source

All Articles