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

https://github.com/api-platform/hypermedia-client

Hypermedia PHP Client
https://github.com/api-platform/hypermedia-client

Last synced: 3 months ago
JSON representation

Hypermedia PHP Client

Awesome Lists containing this project

README

          

# Hypermedia Client

Creates an HTTP Hypermedia client that leverages the [Hydra specification](https://www.hydra-cg.com/)
that makes Web APIs interoperable and set-up PHP classes for each documented API Resource.

## Installation

```console
composer global require api-platform/hypermedia-client
```

Or [download the latest release](https://github.com/api-platform/hypermedia-client/releases).

## Usage

```console
fetch-docs https://pr-500-demo.api-platform.com/docs -vvv --namespace '\App' --directory demo/
```

Fetch the documentation and create resource classes inside the `demo` directory.

```php
getBookCollection();

$book = $books[0];
$book->title = '1984';
$book->patchBook();
```

## Internals

Each resource is created as a PHP class with documented properties and HTTP operations:

```php
# demo/ApiResource/Book.php
$options = null)
*/
#[\ApiPlatform\HypermediaClient\Link(
name: 'getBookCollection',
baseUri: 'https://demo.api-platform.com',
method: 'GET',
output: '\App\Book',
uriTemplatePropertyPath: '@id'
)]
class Book extends \ApiPlatform\HypermediaClient\ApiResource
{
}
```