Description
Consume any APIs with Bearer API client for PHP.
Bearer PHP Client alternatives and similar libraries
Based on the "API" category.
Alternatively, view Bearer PHP Client alternatives based on common mentions on social networks and blogs.
-
Restler
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API -
wsdl2phpgenerator
DISCONTINUED. Simple utility and class library for generating php classes from a wsdl file. -
OverblogGraphQLBundle
This bundle provides tools to build a complete GraphQL API server in your Symfony App. -
Pinterest Bot for PHP
DISCONTINUED. This PHP library will help you to work with your Pinterest account without using any API account credentials. -
Slack for PHP
A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax. -
Drest
Quickly and easily expose Doctrine entities as REST resource endpoints with the use of simple configuration with annotations, yaml, json or a PHP array. -
chubbyphp-framework
A minimal, highly performant middleware PSR-15 microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use. -
cidaas SDK for php
With this SDK, you can integrate cidaas smoothly and with minimal effort into your PHP application. It enables you to map the most important user flows for OAuth2 and OIDC compliant authentication. Secure โ Fast โ And unrivaled Swabian. -
yii2-fractal
A set of utils and actions for build API following JSON:Api specification, based on league/fractal -
icanhazstring/expressive-hashids-middleware
PSR-15/PSR-7 compliant middleware using ivanakimov/hashids.php
InfluxDB - Power Real-Time Data Analytics at Scale
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Bearer PHP Client or a related project?
README
Bearer PHP Client
This is the official PHP client for interacting with Bearer.sh.
Installation
Install the package by running:
composer require bearer/bearer-php
Usage
Get your Bearer Secret Key and integration id from the Dashboard and use the Bearer client as follows:
Calling any APIs
$bearer = new Bearer\Client('BEARER_SECRET_KEY'); // find it on https://app.bearer.sh/keys
$api = $bearer->integration('api_name');
$api->get('/api-endpoint');
More advanced examples
Note: to run the following examples, you'll need to activate the GitHub API first. To activate it, log in to the Dashboard then click on "Add an api" and select "GitHub API".
Passing query parameters
$bearer = new Bearer\Client('BEARER_SECRET_KEY'); // find it on https://app.bearer.sh/keys
$github = $bearer->integration('github');
$github->get('/users/bearer/repos', [ "query" => [ "direction" => "desc" ] ]);
Authenticating users
$bearer = new Bearer\Client('BEARER_SECRET_KEY'); // find it on https://app.bearer.sh/keys
$github = $bearer->integration('github');
$github
->auth("AUTH_ID") // Generate a user identity from the Dashboard
->put('/user/starred/bearer/bearer', [ "headers" => [ "Content-Length" => 0 ] ]);
Available methods
The following methods are available out-of-the-box: GET
, POST
, PUT
, DELETE
, OPTIONS
. If you want to dynamically perform requests, use the request($method)
function:
$bearer = new Bearer\Client('BEARER_SECRET_KEY'); // find it on https://app.bearer.sh/keys
$github = $bearer->integration('github');
$github
->auth("AUTH_ID") // Generate a user identity from the Dashboard
->request('PUT', '/user/starred/bearer/bearer', [ "headers" => [ "Content-Length" => 0 ] ]);
Setting the request timeout
You can customize your http client by specifying httpClientSettings as a Bearer\Client or \$bearer-integration parameter. By default Bearer client request and connection timeouts are set to 5 seconds. Bearer allows to increase the request timeout to up to 30 seconds
$bearer = new Bearer\Client('BEARER_SECRET_KEY', [CURLOPT_TIMEOUT => 10]); // sets timeout to 10 seconds
$github = $bearer->integration('github', [CURLOPT_CONNECTTIMEOUT => 1]); // sets connect timeout to 1 second
$github->get('/repos', [ "query" => [ "direction" => "desc" ] ]);
Learn more on how to use custom functions with Bearer.sh.
Development
Install composer
$ composer install
# run tests
$ vendor/bin/phpunit tests