joeymckenzie / openbrewerydb-php-api
An Open Brewery DB API client for PHP.
Requires
- php: >=8.3
- php-http/discovery: ^1.19.2
- php-http/multipart-stream-builder: ^1.3.0
- psr/http-client: ^1.0.3
- psr/http-client-implementation: *
- psr/http-factory-implementation: *
- psr/http-message: ^2.0.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.8
- laravel/pint: ^1.13
- pestphp/pest: ^2.32
- pestphp/pest-plugin-type-coverage: ^2.8
- pestphp/pest-plugin-watch: ^2.0
- phpstan/phpstan: ^1.10
- phpstan/phpstan-strict-rules: ^1.5
- rector/rector: ^1.0
- symfony/http-client: ^7.0
README
(Un)official PHP bindings for the Open Brewery DB API. Open Brewery DB provides a public dataset for breweries around the world, as well as offering an API to retrieve data in various forms. This library aims to provide straight and easy-to-use PHP bindings for querying the API. The library is inspired by the Open AI client for PHP - please give it star as well!
To get started, first install the package with composer:
$ composer require joeymckenzie/openbrewerydb-php-client
Next, spin up a new client within your code and fire away!
<?php declare(strict_types=1); require_once __DIR__.'/../vendor/autoload.php'; use OpenBreweryDb\OpenBreweryDb; $client = OpenBreweryDb::client(); // Get a list of breweries, based on all types of different search criteria $breweries = $client->breweries()->list([ 'by_city' => 'Sacramento', ]); var_dump($breweries); // Retrieve various metadata about breweries from the API $metadata = $client->breweries()->metadata(); var_dump($metadata); // Get a random brewery with a specified page size $randomBrewery = $client->breweries()->random(5); var_dump($randomBrewery);
The library relies on autodiscovery and will use whichever package that implements PSR-17 within your composer dependencies. You are free to use the HTTP client of you choice, though a popular package is Guzzle.
Though I am not affiliated with organization itself, check out the entire set of APIs offered by Open Brewery DB, check out the docs on their website.