fnayou / zeppelin
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple Guzzle configurator using client configuration and api descriptions files.
1.0.3
2016-09-07 09:10 UTC
Requires
- php: ~5.6|~7.0
- guzzlehttp/guzzle: ~5.0
- guzzlehttp/guzzle-services: ^0.5.0
- symfony/filesystem: ^3.1
- symfony/options-resolver: ^3.1
- symfony/yaml: ^3.1
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ~2.3
- symfony/var-dumper: ^3.1
This package is auto-updated.
Last update: 2024-06-12 03:52:53 UTC
README
[Deprecated and Unmaintained]
Simple Guzzle configurator using client configuration and api descriptions files.
- All you have to do is to create two files :
- the Guzzle client configuration (api url, version, user agent, etc.)
- the API description structure
- use
ZeppelinFactory
factory or create your own - consume APIs
Zeppelin aim to let you focus on your main project by providing a simple and easy way to consume api and web services.
Install
you can install zeppelin using composer
$ composer require fnayou/zeppelin
Usage
- create your Guzzle client configuration file based on the configuration sample file
- create your API description file based on the api description sample file
- use the
ZeppelinFactory
factory with your favoriteLoader
(more loaders will be released soon)
<?php use Fnayou\Zeppelin\Factory\ZeppelinFactory; use Fnayou\Zeppelin\Loader\YamlLoader; $yamlLoader = YamlLoader(); $configurationFilePath = '/path/to/api_configuration.yml'; $customGuzzleConfiguration = []; $client = ZeppelinFactory::build($yamlLoader, $configurationFilePath, $customGuzzleConfiguration);
- consume your APIs
<?php // you can access api as method (according to the api description file) try { $response = $client->user([ 'X-APPID' => '26041986', 'user_id' => 26, ]); } catch (\GuzzleHttp\Exception\RequestException $e) { $response = json_decode($e->getResponse()->getBody()->getContents()); } dump($response);
- you can also create you own
factory
with your own logic, all you have to do is implementFactoryInterface
<?php namespace Vendor\App\Factory; use Fnayou\Zeppelin\ApiClient; use Fnayou\Zeppelin\Api\ApiDescription; use Fnayou\Zeppelin\Factory\FactoryInterface; use Fnayou\Zeppelin\Loader\LoaderInterface; use GuzzleHttp\Client; use GuzzleHttp\Command\Guzzle\GuzzleClient; class CustomFactory implements FactoryInterface { public static function build(LoaderInterface $loader, $filePath, array $config) { // load the guzzle configuration file $apiClientConfiguration = new ApiClient($loader, $filePath); // load the api description file $apiDescription = new ApiDescription( $loader, $apiClientConfiguration->getDescriptionFilePath() ); $client = new Client($apiClientConfiguration->getClientConfiguration()); // your guzzle instance using api description, and custom configuration $zeppelin = new GuzzleClient( $client, $apiDescription->getDescription(), $config ); return $zeppelin; } }
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
- Aymen FNAYOU - GitLab - GitHub
License
The MIT License (MIT). Please see License File for more information.