composer openssl extension is required

错误提示
The openssl extension is required for SSL/TLS protection but is not availab
le. If you can not enable the openssl extension, you can disable this error
, at your own risk, by setting the ‘disable-tls’ option to true. ta errorRet



解决方法:在php.ini文件中打开php_openssl扩展
extension=php_openssl.dll

1,找不到composer
find ~ -name composer.phar



The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl exension, you can disable this error, at your own risk, by setting the ‘disable-tls’ option to true.



这段异常日志的大致意思是,Composer采用SSL连接,需要外挂OpenSSL插件。



要消除这个异常,有两种解决方式,一是放弃SSL连接、直接“裸奔”;二是启用OpenSSL。



取消SSL连接的命令是composer config -g – disable-tls true。然而并没有什么卵用,试过之后,又抛出了新的异常。



requires ext-openssl * -> the requested PHP extension openssl is missing from your system.



剩下来的方案就是尝试启用OpenSSL。安装了PHP后,安装目录(类似C:\php-5.6.24)中包含两个文件,一个是php.ini-development,另一个是php.ini-production,选择将其中任意的一个文件重命名为php.ini,用作PHP的默认配置文件。通过修改配置文件来启用OpenSSL插件。



编辑php.ini文件,首先,定位到:



; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = “./”
; On windows:
extension_dir = “ext”
删除extension_dir = “./”和extension_dir = “ext”前面的分号,取消注释这两行代码,配置PHP插件目录为./ext。



然后,定位到:




;extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll

删除extension=php_openssl.dll前面的分号,取消注释,从而启用OpenSSL插件。



注意:因为SSL连接需要认证,所以继续下面的步骤之前,需要准备好CA证书(建议把证书保存到C:\php-5.6.24\verify目录中),可以从https://curl.haxx.se/docs/caextract.html处下载。



接下来,定位到



;openssl.cafile=
和上面一样,删去分号,取消注释,设置CA证书为openssl.cafile= C:\php-5.6.24\verify\cacert.pem。



/composer.phar -version
You are running Composer with SSL/TLS protection disabled.
Error: “curl” PHP extension not loaded;



Mac OS X中没有默认的php.ini文件,但是有对应的模版文件php.ini.default,位于/private/etc/php.ini.default 或者说 /etc/php.ini/default ,可以自行拷贝一份进行修改。
拷贝命令:



sudo cp /private/etc/php.ini.default /private/etc/php.ini



好安装后生成的配置文件都在/usr/local/etc/php/7.2目录里,分别如下:
php.ini位置为/usr/local/etc/php/7.2/php.ini
php-fpm.conf位置为/usr/local/etc/php/7.2/php-fpm.conf
PHP运行phpize,PHP-配置ls /usr/local/opt/php72/bin
PHP-FPM位置为/usr/local/opt/php72/sbin/php-fpm



$brew services restart php72
Error: Formula php@7.2 is not installed.



https://www.cnblogs.com/wt645631686/p/10898714.html



解决composer install遇到:Your requirements could not be resolved to an installable set of packages



解决办法:直接忽略版本就是了



composer install –ignore-platform-reqs 或者 composer update –ignore-platform-reqs



Category php