承接 pramod/php-api-consumer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pramod/php-api-consumer

Composer 安装命令:

composer require pramod/php-api-consumer

包简介

Php Api Consumer to consume external Url

README 文档

README

This Package developed to request various external api without creating external service or traits.

Installation

You can install the package via composer:

composer require pramod/php-api-consumer

Usage

Please Refer Test Case For Complete Reference which is located in tests/ExampleTest.php

Basic Syntax

Service::consume('fttx-api')
    ->via('customer/pramodk_home')
    ->with([
        'headers'=>[
                    'Authorization'=>'xx',
                    'Content-Type'=>'',
                    'Accept'=>''
                    ],
        'method'=>'POST',
        'version'=>'v1',
        'payload'=>[
            'name'=>'name is here'
        ]
    ])
    ->attach('status_code')
    ->toArray();

Call Your Graphql Api (Next Release)

  1. Add Your Service setting on <<config/api-consumer.php>>
<?php

return [
    'default'=>[
        'timeout'=>10,
        'ssl_verification'=>true,
        'method'=>"GET"
    ],
    'consumer' => [
        'graphqlTest'=>[
            'baseUri'=>'https://countries.trevorblades.com/',
            'timeout'=>60,
            // 'ssl_verification'=>false //my default its true
        ]
    ]
];
  1. Add your endpoint on your request class
    • In case of graphQl key inside with auto set Accept and Content-Type headers as application/json
    • Method is set as POST
    • Need to pass your graphql query in query key
    • Default It call toJson()
return Api::consume('graphqlTest')
            ->via('fcm/graphql')
            ->with([
                'graphQl'=>[
                    'query'=>'query{
                            continents{
                              code
                              name
                              countries{
                                code
                                name
                                native
                              }
                            }
                          }'
                    ]
            ])

List of all public graphql Api to test

https://github.com/APIs-guru/graphql-apis

Descriptions

  1. consume

    Request Or find Service Name mapped in config file having basic application url,version definitions. It has two payload.

     consume($apiHostname, $hosturl)
    

    Default Hosturl will be .wlink.com.np

  2. via

    This method is used to point service end or function name written in service Namespace

    • Available Method
      • first parameter: Api endpoint or uri
      • Second parameter: if second param is true, first param must be method name defined inside your services Folder's class
  3. with

    Includes all parameter including headers, payload, query string and method name

  4. conversion method [By Default it call toJson() method]

    • toArray
    • toJson
    • toCollection
  5. ssl method

    • either true or false, By default its True
  6. timeout method

    • you can pass second value, By Default its 30 seconds
  7. retry method

    • Pass Int value to retry external api, By Default it doesnt retry.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email pramodktwl@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

HAPPY CODING :)

Test

php vendor/phpunit/phpunit/phpunit

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固