LUYA Headless Client ¶
A client library to access content from the LUYA APIs (or any other REST API).
Compared to the other LUYA packages, this package adheres to Semantic Versioning!
Installation ¶
Add the LUYA headless client library to your composer.json:
composer require luyadev/luya-headless
Intro ¶
Quick intro about how to use the headless library with existing built in active endpoints:
use luya\headless\Client;
use luya\headless\modules\admin\ApiAdminUser;
// build client object with token and server infos
$client = new Client('API_TOKEN', 'http://localhost/luya-kickstarter/public_html');
// find a given user by its ID
$user = ApiAdminUser::findOne(1, $client);
// iterate all users
$users = ApiAdminUser::find()->setSort(['id' => SORT_ASC])->all($client);
foreach ($users->getModels() as $user) {
echo $user->firstname . ' ' . $user->lastname;
}
Documentation ¶
See the full Documentation in order to see how to make put, delete or post request, handle pagination or access the cms blocks.
Development and Contribution ¶
- PSR Naming convention: https://www.php-fig.org/bylaws/psr-naming-conventions/
- Cache component require: https://www.php-fig.org/psr/psr-16/ (example implementation, use: https://github.com/symfony/cache
new FilesystemCache('', 0, 'path/to/cache/folder');
) - Unit tests
composer install
and run./vendor/bin/phpunit tests