手动安装 Shippo PHP

Posted

技术标签:

【中文标题】手动安装 Shippo PHP【英文标题】:Installing Shippo PHP Manually 【发布时间】:2017-05-24 13:41:58 【问题描述】:

有没有办法在没有 Composer 或 Laravel 的情况下 文件?

我手动上传了文件,但运行示例时出现错误:

警告: 需要一次(/var/www/html/shippo/examples../../vendor/autoload.php): 无法打开流:没有这样的文件或目录。

我不熟悉 Composer 或 Laravel,也无法让 Composer 工作。

【问题讨论】:

您是否使用了github.com/goshippo/shippo-php-client/blob/master/lib/… 的绝对路径?令人困惑的部分是您仍在使用 vendor/autoload.php 作为 shippo 中的子目录。如果你想在项目中需要 Shippo,你需要像 require('/shippo-php-client/lib/Shippo.php') 这样的东西,它应该包含 Shippo 客户端中的所有内容。 【参考方案1】:

要手动安装库,您需要确保包含shippo-php-client/lib/Shippo.php 的完整路径。所以像:

require('shippo-php-client/lib/Shippo.php')

但是,如果您要走这条路,则需要确保您拥有所有必需的依赖项。该库目前依赖于以下 PHP 扩展:

curl json mbstring

该库被设计为最容易使用 Composer 安装,因为它在 PHP 项目和框架中相当普遍。我仍然建议重新设置并使用 Composer 来管理安装 Shippo 库。

【讨论】:

Shippo 会检查这些,正如您可以在此处看到的那样:***.com/a/62136843/1572383 添加作为答案,因为 cmets 在处理代码示例时效果不佳。 meta.stackexchange.com/questions/77485/…【参考方案2】:

Shippo.php 内部有针对 cURL、JSON 和 mbstring 的测试,所以不用担心。

// Tested on PHP 5.2, 5.3
if (!function_exists('curl_init')) 
    throw new Exception('Shippo needs the CURL PHP extension.');

if (!function_exists('json_decode')) 
    throw new Exception('Shippo needs the JSON PHP extension.');

if (!function_exists('mb_detect_encoding')) 
    throw new Exception('Shippo needs the Multibyte String PHP extension.');

【讨论】:

以上是关于手动安装 Shippo PHP的主要内容,如果未能解决你的问题,请参考以下文章

请教,使用lnmp如何手动安装配置php-fpm,谢谢大家

如何手动安装php slim?

手动安装wamp

ubuntu下手动安装php-amqp模块教程

Centos手动安装PHP

Centos手动安装PHP