Chomp is a Library for extending consumption-only RESTful APIs.
$ composer require anich/chomp dev-master
// YourResource.php
<?php
namespace Your\Namespace;
class YourResource extends \ANich\Chomp\Resource
{
protected $baseUri = 'http://link/to/your/api.com/api/v1/resources/';
}
// OtherFile.php
<?php
require('vendor/autoload.php');
$chomp = new Chomp;
$resource = $chomp->get('\Your\Namespace\YourResource', '1');
echo $resource->id; // 1
echo $resource->title; // Lorem Title.
echo $resource->body; // Lorem ipsum dolor sit amet, consectetur...
// YourResource.php
<?php
namespace Your\Namespace;
class YourResource extends \ANich\Chomp\Resource
{
protected $baseUri = 'http://link/to/your/api.com/api/v1/resources/';
public function titleModifier($title);
{
return 'Title: '.$title;
}
}
// OtherFile.php
<?php
require('vendor/autoload.php');
$chomp = new Chomp;
$resource = $chomp->get('\Your\Namespace\YourResource', '1');
echo $resource->title; // Title: Lorem Title.
(Name your modifiers: fieldModifier)
vendor/bin/phpunit tests
or
composer test
Please see CONTRIBUTING
Please see CHANGELOG
This library is licensed under the MIT license. Please see LICENSE