下午在本地环境用composer安装GuzzleHttp时报错:
G:\AppServ\www\watch>composer require guzzlehttp/guzzle
[Composer\Exception\NoSslException]
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl ex
tension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
解决办法:
打开php.ini,找到#extension=php_openssl.dll;去掉前面的#符号,保存重启Apache。
然后继续安装时又报错:
G:\AppServ\www\watch>composer require guzzlehttp/guzzle
Using version ^6.5 for guzzlehttp/guzzle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
The "https://repo.packagist.org/p/symfony/console.json" file could not be downloaded: failed to open stream: HTTP request failed!
https://packagist.phpcomposer.com could not be fully loaded, package information was loaded from the local cache and may be out of date
解决办法:项目目录下输入composer clear-cache
G:\AppServ\www\watch>composer clear-cache
继续安装,仍然报错:
G:\AppServ\www\watch>composer require guzzlehttp/guzzle
Using version ^6.5 for guzzlehttp/guzzle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Installation failed, reverting ./composer.json to its original content.
[Composer\Downloader\TransportException]
Content-Length mismatch, received 15988 bytes out of the expected 238401
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
解决方法:
更换镜像,注意更换镜像不要进行全局更换的命令 而是要针对这个项目去更换镜像
所以 我们在这个项目的根目录下也就是composer.json的路径下
针对这个项目 进行更换镜像 使用阿里云镜像:输入composer config repo.packagist composer https://mirrors.aliyun.com/composer/
G:\AppServ\www\watch>composer config repo.packagist composer https://mirrors.aliyun.com/composer/
继续安装,成功解决:
G:\AppServ\www\watch>composer require guzzlehttp/guzzle
Using version ^6.5 for guzzlehttp/guzzle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals
- Installing ralouphie/getallheaders (3.0.3): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)
- Installing guzzlehttp/promises (v1.3.1): Downloading (100%)
- Installing guzzlehttp/guzzle (6.5.2): Downloading (100%)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled services file has been removed.