Skip autoload files generation in composer?
So - I have a simple PCR0 auto-loader in my bootstrap.php, that should load any PCR0 compatible library class from 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'm not sure if I understand why composer generates auto-loading files in vendors directory (namely composer directory and autoload.php file) ?
Can I stop Composer from generating those auto-loader files? or am I missing something? I don't think I need them?
There are three autoload related files, each having a different purpose.
Now you mentioned that you have your own PSR-0 classloader, which you are not supposed to use for composer dependencies - you are simply supposed to require/include the vendor/autoload.php and have composer take care of the rest.
This is why there is no option to disable the generation of the autoloading files. In the end composer is supposed to enable you to use the library installed, and enables you by providing all loading you need.
不幸的是,听起来Composer不会支持这个功能:https://github.com/composer/composer/issues/1663
就我个人而言,我将这些文件添加到.gitignore,因为我正在处理的项目有一个自动加载器,可以正常工作
链接地址: http://www.djcxy.com/p/66254.html下一篇: 在作曲家中跳过自动载入文件的生成?