mbvienasbaitas/strapi-php-client

PHP Client wrapper for Strapi API.

1.0.0 2023-01-23 11:17 UTC

This package is auto-updated.

Last update: 2024-10-23 15:47:19 UTC


README

Latest Version on Packagist Test Status Total Downloads

Installation

To get started, simply require the project using Composer.
You will also need to install packages that "provide" psr/http-client-implementation and psr/http-factory-implementation.
A list with compatible HTTP clients and client adapters can be found at php-http.org.

If you don't know which HTTP client to use, we recommend using Guzzle 7:

composer require mbvienasbaitas/strapi-php-client guzzlehttp/guzzle http-interop/http-factory-guzzle:^1.0

Usage

use MBVienasBaitas\Strapi\Client\Client;
use MBVienasBaitas\Strapi\Client\Contracts\Requests\Collection\IndexRequest;
use MBVienasBaitas\Strapi\Client\Contracts\Requests\Options\OptionLocale;
use MBVienasBaitas\Strapi\Client\Contracts\Requests\Options\OptionSortAsc;

$client = new Client('{url}', '{token}');

$request = IndexRequest::make(
    new OptionLocale('en'),
    new OptionSortAsc('title'),
);

$endpoint = $client->collection('articles');

$response = $endpoint->index($request);

More usage examples can be found in examples folder.

Available request options

Each request can accept multiple options. Here is a list of all available options.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

This package structure was inspired by meilisearch-php package.

Alternatives

License

The MIT License (MIT). Please see License File for more information.