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

有没有办法在没有 Composer 或 Laravel 的情况下手动安装 Shippo PHP 文件?

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

警告: 需要一次(/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 客户端中的所有内容。

标签: php autoload shippo


【解决方案1】:

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

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

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

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

【讨论】:

【解决方案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.');
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-12
    • 2013-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多