Download the PHP package gioppy/statamic-rest-client without Composer
On this page you can find all versions of the php package gioppy/statamic-rest-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package statamic-rest-client
This package provide a simple client for Statamic REST API.
It was created primarily for use on SSG php systems, such as Jigsaw, but can be used in any context.
Installation
composer require gioppy/statamic-rest-client
The package needs at least php 8.1, and depend on guzzlehttp/guzzle
and illuminate/collections
.
How to use
After installed, you can create new client with a classic new
operator
new StatamicRestClient(...)
or with a static method
StatamicRestClient::make(...)
You can pass two values: the host of your Statamic installation (e.g: https://www.my-statmic.com
) and optionally the API endpoint path (default is api
but you can customize on Statamic API config).
Filters
You can filter the api using ->where()
method in two possible ways. You can filter single value
or using a condition
Sorting
You can sort the response using ->sort()
method, passing an array of fields:
Selecting fields
You can specify what fields should be included on response using ->fields()
method, passing an array of fields:
Pagination
You can paginate the response using ->paginate()
method, passing the number of items you want and, optionally, the number of page:
Entries / Entry
Get all entries of collection:
Get an entry from a collection:
Collection Tree
TODO
Navigation Tree
Taxonomy Terms / Taxonomy Term
Get all terms of taxonomy:
Get a single term from taxonomy:
Globals / Global
Get all globals:
Get single global:
Assets / Asset
Get all assets of one container:
Get single asset:
Get single asset by its id:
The id
of an asset is formatted by Statamic as container::path
.
Getting response
You can get all response as array, including links and other nodes with ->all()
method
or you can get only data node with ->data()
method
If you need to have data
as collection you can us ->toCollection()
method
Integration with Statamic Glide Rest
Statami Glide Rest is a small addon for Statamic that expose glide manipulation presets on a REST API endpoint. You can get an asset response with a glide presets with the class StatamicGlideRest
:
TODO
- [x] Entries
- [x] Entry
- [ ] Collection Tree
- [x] Navigation Tree
- [x] Taxonomy Terms
- [x] Taxonomy Term
- [x] Assets
- [x] Asset
- [x] Globals
- [x] Global
- [ ] Test
- [x] Integration with Statamic Glide Rest
- [ ] Laravel integration