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.
-
API Platform
Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time. -
PHP-CRUD-API
Single file PHP script that adds a REST API to a SQL database -
Firebase Admin SDK for PHP
Unofficial Firebase Admin SDK for PHP -
Restler
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API -
wsdl2phpgenerator
Simple utility and class library for generating php classes from a wsdl file. -
Hateoas
A PHP library to support implementing representations for HATEOAS REST web services. -
OverblogGraphQLBundle
This bundle provides tools to build a complete GraphQL API server in your Symfony App. -
Pinterest Bot for PHP
This PHP library will help you to work with your Pinterest account without using any API account credentials. -
Symfony DataTables Bundle
DataTables bundle for Symfony -
Symfony GraphQl Bundle
Pure PHP implementation of GraphQL Server – Symfony Bundle -
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. -
Behapi
Behat extension for those who want to write acceptances tests for apis -
Symfony 2 GraphQl Bundle
GraphQL Bundle for Symfony 2. -
yii2-fractal
A set of utils and actions for build API following JSON:Api specification, based on league/fractal -
phpDoc2pdf
Create PDF formatted documentation for your PHP projects -
mite SDK for PHP
Interact with mite from your PHP application. -
Personio SDK for PHP
Interact with Personio from your PHP application. -
icanhazstring/expressive-hashids-middleware
PSR-15/PSR-7 compliant middleware using ivanakimov/hashids.php
Access the most powerful time series database as a service
* 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