【问题标题】:How do I integrate a third-party library into october cms?如何将第三方库集成到 october cms 中?
【发布时间】:2021-01-29 04:21:19
【问题描述】:

我需要将支付系统库添加到我在 Ocrober CMS (https://github.com/yandex-money/yandex-checkout-sdk-php) 上的项目中。对此,问题是:

我可以只使用插件的类来做到这一点,还是有办法自动将它集成到项目中?如果是这样,我怎样才能做到这一点而不重写命名空间并在 php 文件的开头使用? Github上有这方面的资料,但不清楚如何使用。

【问题讨论】:

  • 你可以使用 composer,在你的插件根目录中使用 composer 初始化,并使用 composer require 添加这个库,它将在你的组件/或项目范围内自动可用。
  • @HardikSatasiya 我在我的 openserver 中安装了 composer,我现在如何将这个类(或插件)添加到我的 OctoberCMS 构建中?附言我从未与作曲家合作过,尤其是在十月。

标签: php octobercms octobercms-plugins


【解决方案1】:
  1. 在您的system/server 中安装composer

  2. open terminalgo to in your plugin's root folder 例如。 plugins/author/pluginName

  3. composer require stripe/stripe-php please replace package as per your need

  4. 一旦包安装完成,您就可以使用您的库,例如:$stripeClient = new \Stripe\StripeClient()...

根据您的需要

  1. in terminal 去你的plugin's root directory
  2. composer init -> 然后填写默认信息
  3. composer require yandex-money/yandex-checkout-sdk-php
  4. 在代码中使用
// import 
use YandexCheckout\Client;

// use
$client = new Client();
$client->setAuth('shopId', 'secretKey');

如有任何疑问,请发表评论。

【讨论】:

  • 非常感谢!一切似乎都奏效了。将来,我会阅读文档,因为该工具很有用且非常流行。我已经羞于不知道((
  • 很高兴它对您有所帮助,是的,composer 是很棒的工具 :),学习新事物永远不会晚,现在您知道作曲家欢呼了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-04
  • 2019-12-04
  • 2015-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多