2017 © Pedro Peláez
 

library restinga

Restinga is a framework that allows you to easily consume Rest APIs

image

artesaos/restinga

Restinga is a framework that allows you to easily consume Rest APIs

  • Monday, September 25, 2017
  • by hernandev
  • Repository
  • 6 Watchers
  • 10 Stars
  • 353 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

Restinga

Restinga a is a ActiveResource Framework. What it means? It allows you to consume Rest APIs in a easy and intuitive way. Heavy inspired by Laravel's Eloquent (ActiveRecord Library)., (*1)

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads, (*2)

Documentation

Dig into the Documentation, (*3)

Why it was built?

Well, sometimes the PHP Clients that companies provides sucks, you know it. Sometimes they are even more hard to use than CURLing the API itself. We've built this package to help you when that happens., (*4)

Quick Start Guide

For our quick usage tutorial, let's use Digital Ocean as a example Rest API we want to consume., (*5)

1 - Define the API Service.
<?php namespace Artesaos\DigitalOcean;

use Artesaos\Restinga\Authorization\Bearer;
use Artesaos\Restinga\Service\Descriptor;

class DigitalOceanDescriptor extends Descriptor
{
    // service alias
    protected $service = 'digital-ocean';

    // api prefix
    protected $prefix = 'https://api.digitalocean.com/v2';

    // how to authenticate on the api
    public function authorization()
    {
        return new Bearer('your-token-here');
    }
}
2 - Register the API against the Restinga Container

use Artesaos\DigitalOcean\DigitalOceanDescriptor; use Artesaos\Restinga\Container; Container::register(new DigitalOceanDescriptor());
3 - Define a API Resource
<?php namespace Artesaos\DigitalOcean\Resource;

use Artesaos\Restinga\Data\Resource;
use Artesaos\Restinga\Http\Format\Receive\ReceiveJson;
use Artesaos\Restinga\Http\Format\Receive\ReceiveJsonErrors;
use Artesaos\Restinga\Http\Format\Send\SendJson;

class Droplet extends Resource
{
    // send & receive formats
    use ReceiveJson;
    use SendJson;

    // errors format
    use ReceiveJsonErrors;

    // the service to use (defined on the descriptor)
    protected $service = 'digital-ocean';

    // api resource to consume
    protected $name = 'droplets';

    // resource identifier
    protected $identifier = 'id';

    // resource collection root
    protected $collection_root = 'droplets';

    // resource single item root
    protected $item_root = 'droplet';
}
4 - Use it!
<?php

use Artesaos\DigitalOcean\Resource\Droplet;

$droplet = new Droplet();
$droplet->name = 'server.restinga.dev';
$droplet->region = 'nyc3';
$droplet->size = '512mb';
$droplet->image = 'ubuntu-14-04-x64';

$saved = $droplet->save();

if ($saved) {
    echo $droplet->id; // 4242424
} else {
    foreach ($droplet->errors->all() as $code => $error) {
        echo $code . ": " . $error . "\n";
    }
}

The Versions

25/09 2017

dev-master

9999999-dev

Restinga is a framework that allows you to easily consume Rest APIs

  Sources   Download

MIT

The Requires

 

The Development Requires

by Diego Hernandes

24/09 2017

dev-develop

dev-develop

Restinga is a framework that allows you to easily consume Rest APIs

  Sources   Download

MIT

The Requires

 

The Development Requires

by Diego Hernandes

24/09 2017

1.1.0

1.1.0.0

Restinga is a framework that allows you to easily consume Rest APIs

  Sources   Download

MIT

The Requires

 

The Development Requires

by Diego Hernandes

01/06 2016

1.0.0

1.0.0.0

Restinga is a framework that allows you to easily consume Rest APIs

  Sources   Download

MIT

The Requires

 

The Development Requires

by Diego Hernandes

01/06 2016

0.9.0

0.9.0.0

Restinga is a framework that allows you to easily consume Rest APIs

  Sources   Download

MIT

The Requires

 

The Development Requires

by Diego Hernandes