如何在您的项目中包含 php 库?[开发网站]


How to include a php library in your project ? [developing a website]

我正在尝试在我的项目中包括braintree(提供用于接受在线付款的api)php库。 有没有办法将库复制到服务器中。因为我不熟悉整个作曲家的事情!

GolezTrol 已经回答了这个问题,因为文档说的第一件事是如何在没有作曲家的情况下使用它,但是如果您下载:https://developers.braintreepayments.com/client_libraries/php/braintree-php-3.7.0.tgz

将其上传到您的服务器并将以下内容写入您的网站:

require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';
Braintree'Configuration::environment('sandbox');
Braintree'Configuration::merchantId('your_merchant_id');
Braintree'Configuration::publicKey('your_public_key');
Braintree'Configuration::privateKey('your_private_key');

然后,您可以按照 API 完成该过程。我希望 11 个月后您已经解决了这个问题。

此链接将帮助您启动并运行作曲家 https://getcomposer.org/doc/01-basic-usage.md

只需创建一个composer.json文件并添加以下内容

{
  "require" : {
    "braintree/braintree_php" : "2.35.2"
  }
}

然后运行:

php composer.phar install

或者你可以下载 https://www.braintreepayments.com/assets/client_libraries/php/braintree-php-2.35.2.tgz