Skip to content
/ chomp Public

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

License

Notifications You must be signed in to change notification settings

ANich/chomp

Repository files navigation

Chomp

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages