我通过bitbucket克隆了一个repo,它是一个Magento2项目。
以下是一些具体信息:
Windows环境中使用
ddev
和 docker
。现在,我可以运行
ddev start
,它会返回三个 URL 来访问该网站。
但是当我尝试联系他们每个人时,出现了这个错误:
Warning: require(/var/www/html/vendor/composer/../../app/etc/stores.php): failed to open stream: No such file or directory in /var/www/html/vendor/composer/autoload_real.php on line 82
Fatal error: require(): Failed opening required '/var/www/html/vendor/composer/../../app/etc/stores.php' (include_path='/var/www/html/vendor/magento/zendframework1/library:.:/usr/share/php:/var/www/html/vendor/deployer/recipes') in /var/www/html/vendor/composer/autoload_real.php on line 82
所以我尝试从 shell (
composer install
) 和外部运行 ddev ssh
,但没有成功。
我尝试删除
vendor
文件夹并重新运行 composer install
,但没有成功。
此外,每次我运行
composer install
时,它都无法设置CodeSniffer,如下所示:
Generating autoload files
137 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Failed to set PHP CodeSniffer installed_paths Config
据我了解,问题出在 vendor/composer/ 文件夹中的 autoload_real.php 文件中:
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit95a846f5f47c0550ba8f462ebc5cc61f
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit95a846f5f47c0550ba8f462ebc5cc61f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit95a846f5f47c0550ba8f462ebc5cc61f', 'loadClassLoader'));
$includePaths = require __DIR__ . '/include_paths.php';
$includePaths[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $includePaths));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit95a846f5f47c0550ba8f462ebc5cc61f::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 = Composer\Autoload\ComposerStaticInit95a846f5f47c0550ba8f462ebc5cc61f::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire95a846f5f47c0550ba8f462ebc5cc61f($fileIdentifier, $file);
}
return $loader;
}
}
/**
* @param string $fileIdentifier
* @param string $file
* @return void
*/
function composerRequire95a846f5f47c0550ba8f462ebc5cc61f($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}
我尝试的最后一个命令是
composer dump-autoload
,但结果是相同的。
所以我需要消除网页中的错误,以便能够正确地看到它,并能够以某种方式设置 CodeSniffer。
为什么会出现这个错误,我该如何解决它?
如果有人能帮忙解决这个问题,那就太好了。谢谢大家。
另外,我已经尝试在全局安装CodeSniffer,但并没有解决问题。
从
html
目录运行 vendor/bin/phpcs --config-show
installed_paths
未列出,或者不正确,请运行以下命令:
vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard,../../phpcompatibility/php-compatibility