PHPackages                             simialbi/yii2-rest-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. simialbi/yii2-rest-client

ActiveYii2-extension[HTTP &amp; Networking](/categories/http)

simialbi/yii2-rest-client
=========================

REST client (AR-like model) for Yii Framework 2.0 (via yii2-http-client, extends ApexWire/yii2-restclient)

2.0.1(1y ago)2232.5k↓34.1%10MITPHPPHP &gt;=7.3CI passing

Since Oct 13Pushed 1y ago3 watchersCompare

[ Source](https://github.com/simialbi/yii2-rest-client)[ Packagist](https://packagist.org/packages/simialbi/yii2-rest-client)[ RSS](/packages/simialbi-yii2-rest-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (22)Used By (0)

REST Client for Yii 2 (ActiveRecord-like model)
===============================================

[](#rest-client-for-yii-2-activerecord-like-model)

This extension provides an interface to work with RESTful API via ActiveRecord-like model in Yii 2. It is based on [ApexWire's](https://github.com/ApexWire) [yii2-restclient](https://github.com/ApexWire/yii2-restclient).

[![Latest Stable Version](https://camo.githubusercontent.com/133c5ee6b5e9c0d1dcde0b2974e53d8d525846f54b3f4916fcf81a7f2e89d96d/68747470733a2f2f706f7365722e707567782e6f72672f73696d69616c62692f796969322d726573742d636c69656e742f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/simialbi/yii2-rest-client)[![Total Downloads](https://camo.githubusercontent.com/368f73ed943844a75fd40c61bee4d4253f4ebb814357998d9d5ac24ee32ca601/68747470733a2f2f706f7365722e707567782e6f72672f73696d69616c62692f796969322d726573742d636c69656e742f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/simialbi/yii2-rest-client)[![License](https://camo.githubusercontent.com/cdf109b37c9558a1b84c7d604dbd8c8d7a0b1b54e4ccf0814c15dc8eea71ed91/68747470733a2f2f706f7365722e707567782e6f72672f73696d69616c62692f796969322d726573742d636c69656e742f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/simialbi/yii2-rest-client)[![Build Status](https://github.com/simialbi/yii2-rest-client/workflows/build/badge.svg)](https://github.com/simialbi/yii2-rest-client/workflows/build/badge.svg)

Resources
---------

[](#resources)

- [yii2-restclient](https://github.com/ApexWire/yii2-restclient)
- [\\yii\\db\\ActiveRecord](http://www.yiiframework.com/doc-2.0/guide-db-active-record.html)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ php composer.phar require --prefer-dist simialbi/yii2-rest-client

```

or add

```
"simialbi/yii2-rest-client": "*"

```

to the `require` section of your `composer.json`.

Configuration
-------------

[](#configuration)

To use this extension, configure restclient component in your application config:

```
    'components' => [
        'rest' => [
            'class' => 'simialbi\yii2\rest\Connection',
            'baseUrl' => 'https://api.site.com/',
            // 'auth' => function (simialbi\yii2\rest\Connection $db) {
            //      return 'Bearer: ';
            // },
            // 'auth' => 'Bearer: ',
            // 'usePluralisation' => false,
            // 'useFilterKeyword' => false,
            // 'enableExceptions' => true,
            // 'itemsProperty' => 'items'
        ],
    ],
```

ParameterDefaultDescription`baseUrl``''`The location of the api. E.g. for  the `baseUrl` would be  (required)`auth`Either a Closure which returns a `string` or a `string`. The rest connection will be passed as parameter.`usePluralisation``true`Whether to use plural version for lists (index action) or not (e.g.  instead of `user`)`useFilterKeyword``true`Whether to use "filter" key word in url parameters when filtering (e.g. ?filter\[name\]=user instead of ?name=user`enableExceptions``false`Whether the connection should throw an exception if response is not 200 or not`itemsProperty`If your items are wrapped inside a property (e.g. `items`), set it's name here`requestConfig``[]`Client request configuration`responseConfig``[]`Client response configuration`updateMethod``'put'`The method to use for update operations.`isTestMode``false`Whether we are in test mode or not (prevent execution)`enableQueryCache``false`Whether to enable query caching`queryCacheDuration``3600`The default number of seconds that query results can remain valid in cache`queryCache``'cache'`The cache object or the ID of the cache application componentUsage
-----

[](#usage)

Define your Model

```
