An open API service indexing awesome lists of open source software.

https://github.com/waffler-io/waffler

Declarative HTTP Clients using Guzzle HTTP Library and PHP 8 Attributes
https://github.com/waffler-io/waffler

api api-client api-rest declarative-programming guzzle-php-library guzzlehttp http-client library php php-attibutes php8

Last synced: about 15 hours ago
JSON representation

Declarative HTTP Clients using Guzzle HTTP Library and PHP 8 Attributes

Awesome Lists containing this project

README

          

![Build](https://github.com/waffler-io/waffler/actions/workflows/php-ci.yml/badge.svg)
[![License](https://img.shields.io/github/license/waffler-io/waffler)](LICENSE)
[![Total Downloads](https://img.shields.io/packagist/dt/waffler/waffler.svg)](https://packagist.org/packages/waffler/waffler)

# Waffler


### How to install?

```shell
$ composer require waffler/waffler
```

- This package requires PHP 8 or above.

### How to test?

```shell
$ composer phpunit
```

## Quick start

For our example, lets imagine that we want to consume an ordinary API: `https://foo-bar.baz/api`

Our objectives are:

- Perform the login to retrieve the authorization token.
- Retrieve all posts from the database.

#### Step 1: Create the basic interface for your client.

```php
'']);

// Retrieve the credentials
$credentials = $this->fooClient->login([
'email' => 'email@test.com',
'password' => ''
]);

// Retrieve the posts.
$posts = $this->fooClient->getPosts($credentials['token'], ['created_at' => '2020-01-01'])
```

## Usage examples

See the [Examples folder](./examples).

## Attributes docs

See the [wiki](https://github.com/waffler-io/waffler/wiki/The-Waffler-Attributes) for more information about the Attributes.