2020-02-18 遇到的一点小问题
在centos7上面使用paypal的SDK,选的PHP版本,需要使用composer 。
按composer中文网的描述完成了安装步骤。
[root@wannoo ~]# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
[root@wannoo ~]# php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
[root@wannoo ~]# php composer-setup.php
All settings correct for using Composer
Downloading...
Composer (version 1.9.3) successfully installed to: /root/composer.phar
Use it: php composer.phar
[root@wannoo ~]# php -r "unlink('composer-setup.php');"
因为之前安装PHP选的是XAMPP,所以想着在文件/root/.bash_profile
里加上alias composer=/opt/lampp/bin/composer.phar
,再执行source ~/.bash_profile
,会不会就能正常运行了。
没想到遇到了/usr/bin/env: php: 没有那个文件或目录
,只好在/usr/local/bin
建个PHP的软连接。
[root@wannoo ~]# composer require "paypal/rest-api-sdk-php:*"
/usr/bin/env: php: 没有那个文件或目录
[root@wannoo ~]# ln -s /opt/lampp/bin/php-7.4.2 /usr/local/bin/php
[root@wannoo ~]# composer require "paypal/rest-api-sdk-php:*"
Do not run Composer as root/super user! See https://getcomposer.org/root for details
看到这个提示,以为要切换非root用户,没想到切换后又遇到错误。
[ErrorException]
file_put_contents(./composer.json): failed to open stream: Permission denied
折腾好多命令,后面才这segmentfault看到用户PaulXiang的回答,可以无视这个提示的。
等了一会,不见下载,就设置国内镜像再测试,就可以了。
[root@wannoo ~]# composer config -g repo.packagist composer https://packagist.phpcomposer.com
Do not run Composer as root/super user! See https://getcomposer.org/root for details
[root@wannoo ~]# composer require "paypal/rest-api-sdk-php:*"Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' may remediate them.
- Installing psr/log (1.1.2): Downloading (100%)
- Installing paypal/rest-api-sdk-php (1.14.0): Downloading (100%)
Writing lock file
Generating autoload files
相关代码在/root/vendor/paypal/rest-api-sdk-php
查看
网友评论