shwrm / braintree-bundle
Braintree的PHP客户端库的Symfony 2 Bundle
此软件包的规范存储库似乎已丢失,因此软件包已被冻结。
0.1.3
2016-09-09 10:54 UTC
Requires
- php: >=5.3.2
- braintree/braintree_php: *
Requires (Dev)
- phpspec/phpspec: dev-master
- symfony/framework-bundle: >=2.2,<2.3-dev
This package is auto-updated.
Last update: 2024-05-05 00:54:28 UTC
README
Braintree的PHP客户端库的Symfony 2 Bundle
安装
Composer
只需将以下内容添加到您的composer.json文件中
{ "require": { "cometcult/braintree-bundle": "dev-master" } }
应用程序内核
将Bundle添加到您的应用程序内核中
// app/AppKernel.php public function registerBundles() { return array( // ... new CometCult\BraintreeBundle\CometCultBraintreeBundle(), // ... ); }
配置
# app/config/config.yml # ... comet_cult_braintree: environment: sandbox merchant_id: your_merchant_id public_key: your_public_key private_key: your_private_key
有关配置变量的更多信息,请参阅Braintree文档
用法
Braintree PHP客户端库包含了一组Braintree API的服务。这些服务通常以前缀Braintree_
开头。要查看所有可用的Braintree服务,请访问braintree_php或官方文档。
工厂
获取所需服务的一种方法是调用BraintreeFactory
中的get
方法
// in your controller $factory = $this->get('comet_cult_braintree.factory'); $customerService = $factory->get('customer');
定义一个服务
您可以直接在您的Bundle中定义一个自定义服务,而不是调用工厂
# ../services.yml services: customer_custom_service: class: Braintree_Customer factory_service: comet_cult_braintree.factory factory_method: get arguments: ["customer"]
然后,在您的控制器中,您可以这样做:
$customerService = $this->get('customer_custom_service');