在我的MacOS上运行PHP开发服务器时,我会从作曲家中获得以下错误。
Fatal error: Cannot redeclare composerRequire01a3dc0b1f885ed2b645be37711584c1()
(previously declared in /Users/<user>/Desktop/<app>/vendor/composer/autoload_real.php:63)
in /Users/<user>/Desktop/<app>/vendor/composer/autoload_real.php on line 70
但是,在我的Windows盒上运行完全相同的代码时,一切似乎都很好。我已经确认我并不多次将自动加载的要求陈述包括在内。是什么造成这一点?如果有任何区别,我正在使用Homebrew的作曲家。我只是看不到这样一个特定的文件名称空间是多次包含的。
编辑
作曲家autoload_real.php
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit01a3dc0b1f885ed2b645be37711584c1
{
private static $loader;
public static function loadClassLoader($class)
{
if ('ComposerAutoloadClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit01a3dc0b1f885ed2b645be37711584c1', 'loadClassLoader'), true, true);
self::$loader = $loader = new ComposerAutoloadClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit01a3dc0b1f885ed2b645be37711584c1', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(ComposerAutoloadComposerStaticInit01a3dc0b1f885ed2b645be37711584c1::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = ComposerAutoloadComposerStaticInit01a3dc0b1f885ed2b645be37711584c1::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire01a3dc0b1f885ed2b645be37711584c1($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire01a3dc0b1f885ed2b645be37711584c1($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
似乎您制作了现有项目目录的副本,并尝试将其调整为新目录
尝试删除composer.lock
和vendor/
并运行composer update
我不是100%确定的,但希望它会有所帮助