anich/chomp

A framework for consumption only REST APIs

Maintainers

Details

github.com/ANich/chomp

Source

Issues

Installs: 11

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/anich/chomp

dev-master 2016-06-08 03:01 UTC

This package is not auto-updated.

Last update: 2025-10-11 22:50:47 UTC


README

Chomp is a Library for extending consumption-only RESTful APIs.

Build Status

Installation via Composer

$ composer require anich/chomp dev-master

Basic Usage

// 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...

Modifiers

// 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)

Running Tests

vendor/bin/phpunit tests

or

composer test

Contributing

Please see CONTRIBUTING

Changelog

Please see CHANGELOG

License

This library is licensed under the MIT license. Please see LICENSE