您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
2-4 composer之create-project命令(判断php是否正确配置了证书)
发布时间:2023-05-15 02:57:47编辑:雪饮阅读()
-
以项目形式将一个composer包下载到本地是什么意思?
就以前篇来举例,之前我们是在basic目录里面删除vendor然后通过vendor同目录的composer.json来install的。
那么这里我们就是直接退出basic目录将basic目录删除,并在basic目录同级目录使用composer创建项目名为basic的项目,那么这样下来的就是整个basic目录了,不用再进入basic目录内部通过那个composer.json进行install了
以上应该就是该概念的公共项目创建流程原理。
那么这里的意思是要先composer全局global安装fxp/composer-asset-plugin
如:
D:\phpstudy_pro\Extensions\php\php5.5.9nts\php.exe -c D:\phpstudy_pro\Extensions\php\php5.5.9nts\php.ini D:\phpstudy_pro\Extensions\composer185.phar global require "fxp/composer-asset-plugin:~1.0.0"
然后如
D:\phpstudy_pro\Extensions\php\php5.6.9nts\php.exe -c D:\phpstudy_pro\Extensions\php\php5.6.9nts\php.ini D:\phpstudy_pro\Extensions\composer200.phar create-project yiisoft/yii2-app-basic basic
但是我这里最后老出现如这样的错误
[Composer\Downloader\TransportException]
SSL certificate problem: unable to get local issuer certificate
问题一直不得解,这里挺复杂的因为composer有1和2两个大版本的区分。然后还有composer自身的ssl校验配置、还涉及composer自身证书与git证书以及所用镜像服务端自身问题等,以及php的证书。
那么问题那么复杂,我这里也就不一一排查了,反正实际项目中我实在不行我就以下载存档的方式安装不就行了。。。
那么这里我主要是分享下怎么判断php的证书是加载成功了的
首先说说php证书配置是要在这个地方下载证书
https://curl.haxx.se/ca/cacert.pem
然后配置在php.ini中一般有两种方式
如下面这两种
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo =D:\phpstudy_pro\Extensions\php\php5.6.9nts\cacert.pem
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile=D:\phpstudy_pro\Extensions\php\php5.6.9nts\cacert.pem
; If openssl.cafile is not specified or if the CA file is not found, the
; directory pointed to by openssl.capath is searched for a suitable
; certificate. This value must be a correctly hashed certificate directory.
; Most users should not specify a value for this directive as PHP will
; attempt to use the OS-managed cert stores in its absence. If specified,
; this value may still be overridden on a per-stream basis via the "capath"
; SSL stream context option.
;openssl.capath=
; Local Variables:
; tab-width: 4
; End:
这是因为不同php版本配置上应该是有所不同,当然这是我自己研究下来的个人见解了。
然后接下来就是分享下判断php是否正确配置了ssl证书
<?php
$url = 'https://www.baidu.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($ch);
if (curl_errno($ch) == 0) {
echo 'SSL load success';
} else {
echo 'SSL load fail:' . curl_error($ch);
}
curl_close($ch);
?>
关键字词:composer,create-project