offshoot/vend-php
最新稳定版本:1.0.0
Composer 安装命令:
composer require offshoot/vend-php
包简介
Simple Vend API client in PHP
关键字:
README 文档
README
A simple Vend API client in PHP.
The canoncial repository for this stream of development is https://github.com/TeamOffshoot/vend-php
Requirements
- PHP 5.3 (or higher)
- ext-curl, ext-json
- offshoot/http
Development Requirements
- phpunit/phpunit 3.7
Getting Started
Install vend-php via Composer
Create a composer.json file if you don't already have one in your projects
root directory and require vend-php:
{
"require": {
"offshoot/vend-php": "~1.0"
}
}
To learn more about Composer, including the complete installation process, visit http://getcomposer.org/
Using cURL
If you're using a cURL based HttpClient like the CurlHttpClient, you will want
to include the cacert.pem file that can be found at
http://curl.haxx.se/docs/caextract.html
You can add this as a dependency in your composer file. Your composer.json
might look something like this:
{
"require": {
"offshoot/vend-php": "~1.0",
"haxx-se/curl": "1.0.0"
},
"repositories": [
{
"type": "package",
"package": {
"name": "haxx-se/curl",
"version": "1.0.0",
"dist": {
"url": "http://curl.haxx.se/ca/cacert.pem",
"type": "file"
}
}
}
]
}
You will be able to find the cacert.pem file in vendor/haxx-se/curl/cacert.pem
Usage
Authentication
Getting an Access Token
If you do not already have a Vend API Permanent Access Token, you will need you authenticate with the Vend API first
$pathToCertificateFile = 'vendor/haxx-se/curl/cacert.pem';
$httpClient = new \Offshoot\HttpClient\CurlHttpClient($pathToCertificateFile);
$redirector = new \Offshoot\Redirector\HeaderRedirector();
$authenticate = new \Vend\Api\AuthenticationGateway($httpClient, $redirector);
$authenticate->forStoreName('mycoolstore')
->usingClientId('XXX1234567890') // get this from your Vend Account
->andReturningTo('http://wherever.you/like')
->initiateLogin();
This will redirect your user to a Vend login screen where they will need to authenticate with their Vend credentials. After doing that, Vend will perform a GET request to your redirect URI, that will look like:
GET http://wherever.you/like?code=TEMP_TOKEN&domain_prefix=YOUR_STORE_NAME
Your application will need to capture the code query param from the request
and use that to get the access token from Vend
// validate the Vend Request
if ($client->isValidRequest($_GET)) {
// exchange the token
$accessToken = $authenticate->forStoreName('mycoolstore')
->usingClientId('XXX1234567890') // get this from your Vend Account
->usingClientSecret('ABC123XYZ') // get this from your Vend Account
->andReturningTo('http://wherever.you/like')
->toExchange($_GET['code']);
}
Refreshing an Access Token
TBD
Interacting with the Vend API
Set up the API Client
$vend = new \Vend\Api\Client($httpClient);
$vend->setStoreName('mycoolstore');
$vend->setAccessToken($accessToken);
Contributing
Contributions are welcome. Just fork the repository and send a pull request. Please be sure to include test coverage with your pull request. You can learn more about Pull Requests here
In order to run the test suite, ensure that the development dependencies have been installed via composer. Then from your command line, simple run:
vendor/bin/phpunit --bootstrap tests/bootstrap.php tests/
License
This library is released under the GPL 3.0 License
Acknowledgements
Thanks to Bruce Aldridge for his development of the initial code base.
offshoot/vend-php 适用场景与选型建议
offshoot/vend-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.73k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2014 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「shop」 「e-commerce」 「shopping」 「vend」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 offshoot/vend-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 offshoot/vend-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 offshoot/vend-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Implementation of the Omnibus Directive for Sylius application.
Laravel 11 and above Shopping cart
Livewire starter kit for Lunar e-commerce.
Admin Hub for GetCandy. A modern headless e-commerce solution for Laravel PHP framework.
Submodule for SilverShop which allows you to compare products in a table.
Automatically translate and review your content via Lokalise.
统计信息
- 总下载量: 3.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-16