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
- Host: GitHub
- URL: https://github.com/api-platform/hypermedia-client
- Owner: api-platform
- License: mit
- Created: 2025-02-03T13:58:11.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-02-05T07:05:29.000Z (12 months ago)
- Last Synced: 2025-10-06T20:55:30.939Z (3 months ago)
- Language: PHP
- Size: 91.8 KB
- Stars: 6
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
{
}
```