netflex/api
最新稳定版本:v6.7.3
Composer 安装命令:
composer require netflex/api
包简介
Netflex API library
README 文档
README
[READ ONLY] Subtree split of the Netflex API component (see netflex/api)
A library for working with the Netflex API.
Table of contents
Installation
1. Setup
composer require netflex/api
Note: If you are using Netflex SDK 2.0 or later, or Laravel 5.5, the steps 2 and 3, for providers and aliases, are unnecessaries. Netflex API supports Package Discovery.
2. Provider
You need to update your application configuration in order to register the package so it can be loaded by Laravel, just update your config/app.php file adding the following code at the end of your 'providers' section:
config/app.php
<?php return [ // ... 'providers' => [ Netflex\API\Providers\APIServiceProvider::class, // ... ], // ... ];
3. Facades
You may get access to the Netflex API using following facades:
Netflex\API\Facades\API
You can setup a short-version aliases for these facades in your config/app.php file. For example:
<?php return [ // ... 'aliases' => [ 'API' => Netflex\API\Facades\API::class, // ... ], // ... ];
4. Configuration
Publish config
In your terminal type
php artisan vendor:publish
or
php artisan vendor:publish --provider="Netflex\API\Providers\APIServiceProvider"
Alternatively, you can create the config file manually, under config/api.php, see example here.
Standalone usage
Netflex API can be used standalone as well.
<?php use Netflex\API\Client; $client = new Client([ 'auth' => ['publicKey', 'privateKey'] ]);
Testing
For testing purposes, use the provided Netflex\API\Testing\MockClient implementation.
This can be used with the Facade, so you don't have to modify your code while testing.
To bind the MockClient into the container, register the Netflex\API\Testing\Providers\MockAPIServiceProvider provider.
Example:
<?php use Illuminate\Container\Container; use Illuminate\Support\Facades\Facade; use Netflex\API\Facades\API; use Netflex\API\Testing\Providers\MockAPIServiceProvider; use GuzzleHttp\Psr7\Response; $container = new Container; Facade::setFacadeApplication($container); // Register the service provider (new MockAPIServiceProvider($container))->register(); // The container binding is now registered, and you can use the Facade. API::mockResponse( new Response( 200, ['Content-Type' => 'application/json'], json_encode(['hello' => 'world']) ) ); $response = API::get('/'); // Returns the mocked response echo $response->hello; // Outputs 'world'
统计信息
- 总下载量: 4.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 15
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-10