sellerlabs / modernmws-php
v0.3.0
2016-09-15 22:05 UTC
Requires
- guzzlehttp/guzzle: ~6.0
- nesbot/carbon: ^1.19
- sellerlabs/nucleus: 0.5.*
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ^4.7
- sami/sami: ~3.0
Conflicts
This package is not auto-updated.
Last update: 2019-02-20 18:27:33 UTC
README
这是SellerLabs研究API服务的官方PHP客户端库(之前称为NodeMWS/ModernMWS客户端)。
需求
- PHP +5.6或HHVM +3.6。
- Composer和
autoload.php
。 - 当然:使用研究服务的凭证。
文档
- 研究服务的API文档可在以下网址查看:https://docs.sellerlabs.com/research/
- 此库的文档位于本存储库的
docs
目录中,可在http://sellerlabs.github.io/research-php/上在线查看。
安装与使用
使用composer
首先,将包添加到您的composer.json
文件中
// ... "require": { "sellerlabs/research-php": "*" } // ...
然后运行composer update
如何在Laravel 5中使用
首先,您需要在内置应用程序服务提供者中配置客户端
public function register() { $this->app->bind( SellerLabs\Research\Interfaces\ResearchClientInterface::class, function () { return new ResearchClient( 'YourClientId', 'YourClientSecret', 'http://research.api.sellerlabs.com' ); } ); }
然后,在您的任何控制器中,您可以通过构造函数注入依赖项
// ... class ProductsController extends Controller { /** * Implementation of a client for SellerLabs' research API * * @var ResearchClientInterface */ protected $researchClient; /** * Construct an instance of a ProductsController */ public function __construct(ResearchClientInterface $researchClient) { $this->researchClient = $researchClient; } /** * Handle GET /products/ */ public function getIndex() { return $this->researchClient->getSearch('keyword', 'testing'); } }
Laravel的容器足够智能,可以自动执行依赖注入,当初始化控制器类时,它会为您添加客户端参数