99designs / relax
A library for consuming simple REST services in PHP5.
Installs: 40 081
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 48
Forks: 0
Open Issues: 0
Requires
- php: >=5.3
- 99designs/ergo-http: 1.*
Requires (Dev)
- mockery/mockery: 0.7.*
- phpunit/phpunit: 3.*
This package is not auto-updated.
Last update: 2020-01-24 15:15:39 UTC
README
Relax is a client designed to interact with APIs that conform to the following:
- Return JSON
- Respond to GET, PUT AND POST
- Urls map to the pattern of /collection/123/subcollection/234
Relax also provides a set of Openssl helper classes.
<?php $client = new \Ergo\Http\Client("http://mywebservice.io"); $model = new Relax_Client_Model($client); $model ->hasMany( $model->define('Transaction') ->hasMany('PaymentDevice') ->hasMany('PaymentIntention') ->hasMany('TransactionItem','items','item') ) ->hasMany( $model->define('Customer') ->hasOne('Address') ) ; // GET queries $items = $model->transactions(1)->items(); // returns a collection from /transactions/1/items $address = $model->customers(1)->address(); // returns a resource from /customers/1/address print $address->streetname; // returns the streetname property from the json doc print $items->count(); // returns the number of items in the transaction // PUT queries $model->customers()->create(array('i'=>'x')); // POST queries $model->customers(1)->set('name','Fred')->save();
Copyright
Copyright (c) 2012 99designs See LICENSE for details.