99designs / relax
此包已被废弃且不再维护。未建议替代包。
一个用于在PHP5中消费简单REST服务的库。
2.0.0
2014-11-17 04:04 UTC
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是一个客户端,用于与符合以下标准的API进行交互
- 返回JSON
- 响应GET、PUT和POST
- URL映射到/collection/123/subcollection/234的模式
Relax还提供了一套OpenSSL辅助类。
<?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();
版权
版权所有(c)2012 99designs。有关详细信息,请参阅LICENSE。