2017 © Pedro Peláez
 

luya-core luya-headless

LUYA headless API client

image

luyadev/luya-headless

LUYA headless API client

  • Wednesday, July 25, 2018
  • by nadar
  • Repository
  • 3 Watchers
  • 2 Stars
  • 216 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 3 Open issues
  • 3 Versions
  • 67 % Grown

The README.md

LUYA Logo , (*1)

LUYA Headless Client

A client library to access content from the LUYA APIs (or any other REST API)., (*2)

LUYA Tests Latest Stable Version Maintainability Test Coverage Total Downloads, (*3)

Installation

Add the LUYA headless client library to your composer.json:, (*4)

composer require luyadev/luya-headless

Intro

Quick intro about how to use the headless library with a custom Endpoint: Create the Api Class (this very similar to Active Record pattern):, (*5)

class ApiCars extends \luya\headless\ActiveEdnpoint
{
    public $id;
    public $name;
    public $year;

    public function getEndpointName()
    {
        return '{{api-cars}}';
    }
}

With the new ApiCars class you can now insert, update or fetch data:, (*6)

use luya\headless\Client;

// build client object with token and server infos
$client = new Client('API_TOKEN', 'http://localhost/luya-kickstarter/public_html');

// create new value
$car = new ApiCars();
$car->name = 'BMW';
$car->year = 2019;
$car->save($client);

// find a given user by its ID
$car = ApiCars::viewOne(1, $client);
echo $car->name; // BMW
echo $car->year; // 2019

// update an existing value
$car->year = '2018';
$car->save($client);

// iterate all cars
$users = ApiCars::find()->setSort(['id' => SORT_ASC])->all($client);
foreach ($users->getModels() as $car) {
      echo $car->name;
}

Documentation

See the full Documentation in order to see how to make put, delete or post request, handle pagination or access the cms blocks., (*7)

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

The Versions

25/07 2018

dev-master

9999999-dev https://luya.io

LUYA headless API client

  Sources   Download

MIT

The Requires

 

The Development Requires

php yii2 headless luya

16/07 2018

1.0.0-beta

1.0.0.0-beta https://luya.io

LUYA headless API client

  Sources   Download

MIT

The Requires

 

The Development Requires

php yii2 headless luya

10/07 2018

1.0.0-alpha

1.0.0.0-alpha https://luya.io

LUYA headless API client

  Sources   Download

MIT

The Requires

 

The Development Requires

php yii2 headless luya