先说说基本情况,Magento2.3.4的系统,从线上git clone到本机搞开发环境,配置好域名后,打开域名就给我报了Vendor autoload is not found. Please run 'composer install' under application root directory.

很明显git clone下载的系统,并不会把Vendor目录等信息copy到我本机,这种情况下,可以直接用ftp下载站点代码来解决

但本着学习的心态,试试不同的安装方式,使用composer install来安装magento系统,入一下composer install安装的坑吧,记录一下所有安装过程遇到的问题及解决方案:


一、按提示进入网站根目录,执行composer install,结果报了以下错误

vice@srv /v/w/h/demo_m2_234 (master)> composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for amzn/amazon-pay-sdk-php 3.6.0 -> satisfiable by amzn/amazon-pay-sdk-php[3.6.0].
    - amzn/amazon-pay-sdk-php 3.6.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
    
****省略******
   
    - Installation request for amzn/amazon-pay-and-login-with-amazon-core-module 3.3.1 -> satisfiable by amzn/amazon-pay-and-login-with-amazon-core-module[3.3.1].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.3/cli/php.ini
    - /etc/php/7.3/cli/conf.d/10-mysqlnd.ini
****省略****** 
    - /etc/php/7.3/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.3/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

二:查看了一下根目录的文件,存在composer.lock文件,于是先重命名为composer.lock.bak,再尝试composer install,操作如下

vice@srv /v/w/h/demo_m2_234 (master)> mv composer.lock composer.lock.bak
vice@srv /v/w/h/demo_m2_234 (master)> composer install
Loading composer repositories with package information
Warning from repo.magento.com: You haven't provided your Magento authentication keys. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html
    Authentication required (repo.magento.com):
      Username: 
提示我输入magento账户

三:输入magento登录的账号密码后,出现以下错误

Warning from repo.magento.com: Your Magento authentication keys are invalid. Please double-check your keys in your Marketplace account. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html
Warning from repo.magento.com: Your Magento authentication keys are invalid. Please double-check your keys in your Marketplace account. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html
Warning from repo.magento.com: Your Magento authentication keys are invalid. Please double-check your keys in your Marketplace account. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html

PHP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Console\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Application.php:1217
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Application.php(884): Symfony\Component\Console\Application->splitStringByWidth('Invalid credent...', 185)
#1 /usr/share/php/Symfony/Component/Console/Application.php(859): Symfony\Component\Console\Application->doActuallyRenderThrowable(Object(Composer\Downloader\TransportException), Object(Symfony\Component\Console\Output\StreamOutput))
#2 /usr/share/php/Symfony/Component/Console/Application.php(822): Symfony\Component\Console\Application->doRenderThrowable(Object(Composer\Downloader\TransportException), Object(Symfony\Component\Console\Output\StreamOutput))
#3 /usr/share/php/Symfony/Component/Console/Application.php(131): Symfony\Component\Console\Application->renderThrowable(Object(Composer\Downloader\TransportException), Object(Symfony\Component\Console\Output\StreamOutput))
#4 /usr/share/php/Sym in /usr/share/php/Symfony/Component/Console/Application.php on line 1217

关键的第一句Warning from repo.magento.com: Your Magento authentication keys are invalid. Please double-check your keys in your Marketplace account. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html,好吧,复制连接进入看了一下,再google查查错误信息。

异常原因:其实就是没有magento插件市场的key,注册magento用户登录后创建key,再重新用composer install进行安装,找到解决两个方案

三 (1):把账号/密码换成magento的Public Key/Private Key,操作如下

vice@srv /v/w/h/demo_m2_234 (master) [SIGINT]> composer install -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Failed to initialize global composer: Composer could not find the config file: /home/vice/.config/composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running 1.10.1 (2020-03-13 20:34:27) with PHP 7.3.15-3 on Linux / 5.4.0-kali4-amd64
Loading composer repositories with package information
Downloading https://repo.magento.com/packages.json
Warning from repo.magento.com: You haven't provided your Magento authentication keys. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html
    Authentication required (repo.magento.com):
      Username: 238cfcfe268f5a9259156907005c7de5
      Password: 
Using HTTP basic authentication with username "238cfcfe268f5a9259156907005c7de5"
Downloading https://repo.magento.com/packages.json
Do you want to store credentials for repo.magento.com in /home/vice/.config/composer/auth.json ? [Yn] y
composer install 加-vvv是为了把所有的过程显示出来,要不然过程太久看不到详细的过程总会以为卡死了

三 (2):将站点根目录下的auth.json.sample复制为auth.json,再编辑auth.json加入magento的Public Key/Private Key(此方案未验证)

本以为这样处理就正常了,结果还是回到刚开始的问题最初错误提示,再细看错误提示,(好像是用php7.3的版本,magento库需要的是php7.1-7.2的版本),composer install使用php的版本不对?本机安装了5.6、7.1、7.2、7.3四个不同的版本!那么用对php版本来执行是否可行?又查了老久,确认了三种处理方案,如下:

四 (1):修改composer.json,在confing增加配置,指定php版本,如下

    "config": {
	 "platform" :{
	             "php": "7.1"
	 },
        "preferred-install": "dist",
        "sort-packages": true
    },
新增加platform这3行,再次执行还是用php7.3版本来执行composer install,结果失败

四 (2):命令行指定php版本来执行composer install,如下

vice@srv /v/w/h/demo_m2_234 (master) [SIGINT]> 
php7.1 composer install -vvv
Could not open input file: composer
vice@srv /v/w/h/demo_m2_234 (master) [1]> 
/usr/bin/php7.1 composer install -vvv
Could not open input file: composer
vice@srv /v/w/h/demo_m2_234 (master) [SIGINT]> php7.1 /usr/bin/composer install -vvv
每三次,指定composer的脚本路径就能正常引用php7.1来调用composer install

php7.1 composer install 安装过程很花时间,等了好久,报了以下错误:

  - Installing zendframework/zend-http (2.11.2): Downloading https://api.github.com/repos/zendframework/zend-http/zipball/e15e0ce45a2a4f642cd0b7b4f4d4d0366b729a1a
Downloading (failed)       
    Download failed, retrying...
Downloading https://api.github.com/repos/zendframework/zend-http/zipball/e15e0ce45a2a4f642cd0b7b4f4d4d0366b729a1a
Downloading (failed)       
    Download failed, retrying...
Downloading https://api.github.com/repos/zendframework/zend-http/zipball/e15e0ce45a2a4f642cd0b7b4f4d4d0366b729a1a
Downloading (failed)       
Failed: [Composer\Downloader\TransportException] 0: The "https://api.github.com/repos/zendframework/zend-http/zipball/e15e0ce45a2a4f642cd0b7b4f4d4d0366b729a1a" file could not be downloaded: SSL: Connection reset by peer
Failed to enable crypto
failed to open stream: operation failed
    Failed to download zendframework/zend-http from dist: The "https://api.github.com/repos/zendframework/zend-http/zipball/e15e0ce45a2a4f642cd0b7b4f4d4d0366b729a1a" file could not be downloaded: SSL: Connection reset by peer
Failed to enable crypto
failed to open stream: operation failed
    Now trying to download from source
  - Installing zendframework/zend-http (2.11.2): Executing command (CWD): git --version

    Cloning to cache at '/home/vice/.cache/composer/vcs/https---github.com-zendframework-zend-http.git/'
Executing command (CWD): git clone --mirror 'https://github.com/zendframework/zend-http.git' '/home/vice/.cache/composer/vcs/https---github.com-zendframework-zend-http.git/'
Cloning e15e0ce45a2a4f642cd0b7b4f4d4d0366b729a1a
Executing command (CWD): git clone --no-checkout 'https://github.com/zendframework/zend-http.git' '/var/www/html/demo_m2_234/vendor/zendframework/zend-http' && cd '/var/www/html/demo_m2_234/vendor/zendframework/zend-http' && git remote add composer 'https://github.com/zendframework/zend-http.git' && git fetch composer && git remote set-url origin 'https://github.com/zendframework/zend-http.git' && git remote set-url composer 'https://github.com/zendframework/zend-http.git'
Failed: [Symfony\Component\Process\Exception\ProcessTimedOutException] The process "git clone --no-checkout 'https://github.com/zendframework/zend-http.git' '/var/www/html/demo_m2_234/vendor/zendframework/zend-http' && cd '/var/www/html/demo_m2_234/vendor/zendframework/zend-http' && git remote add composer 'https://github.com/zendframework/zend-http.git' && git fetch composer && git remote set-url origin 'https://github.com/zendframework/zend-http.git' && git remote set-url composer 'https://github.com/zendframework/zend-http.git'" exceeded the timeout of 300 seconds.

In Process.php line 1253:
                                                                               
  [Symfony\Component\Process\Exception\ProcessTimedOutException]               
  The process "git clone --no-checkout 'https://github.com/zendframework/zend  
  -http.git' '/var/www/html/demo_m2_234/vendor/zendframework/zend-http' && cd  
   '/var/www/html/demo_m2_234/vendor/zendframework/zend-http' && git remote a  
  dd composer 'https://github.com/zendframework/zend-http.git' && git fetch c  
  omposer && git remote set-url origin 'https://github.com/zendframework/zend  
  -http.git' && git remote set-url composer 'https://github.com/zendframework  
  /zend-http.git'" exceeded the timeout of 300 seconds.                        
                                                                               

Exception trace:
  at /usr/share/php/Symfony/Component/Process/Process.php:1253
 Symfony\Component\Process\Process->checkTimeout() at /usr/share/php/Symfony/Component/Process/Process.php:417
****省略******
/usr/share/php/Composer/Console/Application.php:113
 Composer\Console\Application->run() at /usr/bin/composer:62

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>...]

尝试以前的解决方案换composer的镜像,再执行composer install

vice@srv /v/w/h/demo_m2_234 (master)>composer config -g repo.packagist composer https://packagist.phpcomposer.com
vice@srv /v/w/h/demo_m2_234 (master)>php7.1 /usr/bin/composer install -vvv

四 (3) : 直接忽略php版本执行composer install --ignore-platform-reqs 或者 composer update --ignore-platform-reqs(此方案未验证)

最后感谢以下的分享:

Warning from repo.magento.com: Your Magento authentication keys are invalid. Please double-check your keys in your Marketplace account. For instructions, 错误的参考:

https://magento.stackexchange.com/questions/90983/how-to-use-the-new-repo-magento-com

https://community.magento.com/t5/Magento-2-x-Version-Upgrades/Invalid-credentials-for-https-repo-magento-com-packages-json/td-p/22287

Your requirements could not be resolved to an installable set of packages.与To enable extensions, verify that they are enabled in your,错误的参考

解决composer install遇到:Your requirements could not be resolved to an installable set of packages_JavaScript_IT-Andy-CSDN博客
首先看报错信息:如下图解决办法:直接忽略版本就是了composerinstall--ignore-pJavaScript
多个php版本的composer使用 - 周伯通的麦田 - 博客园
由于系统环境变量之前同事安装的laravel是5.1...php默认的环境变量是: 不想破话原有环境变量,因为现在新的项目是laravel5.4.。。所以在用默认composer require安装时