php 为什么composer无法在Magento2项目的克隆中设置CodeSniffer?

fdbelqdn  于 2024-01-05  发布在  PHP
关注(0)|答案(1)|浏览(202)

我通过比特桶克隆了一个回购协议,这是一个Magento 2项目。
以下是一些细节:

  • 我在Windows环境中同时使用ddevdocker
  • 我使用过Ubuntu 18.04版
    php 7.4.1版
    *** composer v2
    *

现在,我可以运行ddev start,它会返回三个 * URL * 来访问该网站。
但是当我尝试访问他们每一个人的时候,出现了这样的错误:

  1. 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
  2. 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(ddev ssh)和外部运行composer install,但没有成功。
我尝试删除vendor文件夹并重新运行composer install,但没有成功。
此外,每次运行composer install时,它都无法设置CodeSniffer,如下所示:

  1. Generating autoload files
  2. 137 packages you are using are looking for funding.
  3. Use the `composer fund` command to find out more!
  4. Failed to set PHP CodeSniffer installed_paths Config


正如我所理解的,问题出在 vendor/composer/ 文件夹中的这个autoload_真实的.php文件中:

  1. <?php
  2. // autoload_real.php @generated by Composer
  3. class ComposerAutoloaderInit95a846f5f47c0550ba8f462ebc5cc61f
  4. {
  5. private static $loader;
  6. public static function loadClassLoader($class)
  7. {
  8. if ('Composer\Autoload\ClassLoader' === $class) {
  9. require __DIR__ . '/ClassLoader.php';
  10. }
  11. }
  12. /**
  13. * @return \Composer\Autoload\ClassLoader
  14. */
  15. public static function getLoader()
  16. {
  17. if (null !== self::$loader) {
  18. return self::$loader;
  19. }
  20. require __DIR__ . '/platform_check.php';
  21. spl_autoload_register(array('ComposerAutoloaderInit95a846f5f47c0550ba8f462ebc5cc61f', 'loadClassLoader'), true, true);
  22. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
  23. spl_autoload_unregister(array('ComposerAutoloaderInit95a846f5f47c0550ba8f462ebc5cc61f', 'loadClassLoader'));
  24. $includePaths = require __DIR__ . '/include_paths.php';
  25. $includePaths[] = get_include_path();
  26. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  27. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  28. if ($useStaticLoader) {
  29. require __DIR__ . '/autoload_static.php';
  30. call_user_func(\Composer\Autoload\ComposerStaticInit95a846f5f47c0550ba8f462ebc5cc61f::getInitializer($loader));
  31. } else {
  32. $map = require __DIR__ . '/autoload_namespaces.php';
  33. foreach ($map as $namespace => $path) {
  34. $loader->set($namespace, $path);
  35. }
  36. $map = require __DIR__ . '/autoload_psr4.php';
  37. foreach ($map as $namespace => $path) {
  38. $loader->setPsr4($namespace, $path);
  39. }
  40. $classMap = require __DIR__ . '/autoload_classmap.php';
  41. if ($classMap) {
  42. $loader->addClassMap($classMap);
  43. }
  44. }
  45. $loader->register(true);
  46. if ($useStaticLoader) {
  47. $includeFiles = Composer\Autoload\ComposerStaticInit95a846f5f47c0550ba8f462ebc5cc61f::$files;
  48. } else {
  49. $includeFiles = require __DIR__ . '/autoload_files.php';
  50. }
  51. foreach ($includeFiles as $fileIdentifier => $file) {
  52. composerRequire95a846f5f47c0550ba8f462ebc5cc61f($fileIdentifier, $file);
  53. }
  54. return $loader;
  55. }
  56. }
  57. /**
  58. * @param string $fileIdentifier
  59. * @param string $file
  60. * @return void
  61. */
  62. function composerRequire95a846f5f47c0550ba8f462ebc5cc61f($fileIdentifier, $file)
  63. {
  64. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  65. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  66. require $file;
  67. }
  68. }


我试过的最后一个命令是composer dump-autoload,但结果是一样的。
因此,我需要消除网页中的错误,以便能够正确地看到它,并能够以某种方式设置CodeSniffer。
为什么会出现此错误?如何解决此错误?
如果有人能帮上忙,那就太棒了,谢谢你们。
另外,我已经尝试在全局范围内安装CodeSniffer,但它没有解决问题。

hc2pp10m

hc2pp10m1#

html目录运行vendor/bin/phpcs --config-show
如果installed_paths未列出或不正确,请运行以下命令:

  1. vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard,../../phpcompatibility/php-compatibility

字符串

相关问题