Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 1.39 KB

README_EN.md

File metadata and controls

77 lines (54 loc) · 1.39 KB

Yii2 Rest Client

Tools to use API as ActiveRecord for Yii2

Use your API as ActiveRecord

Installation

The preferred way to install this yii2-extension is through composer.

Either run

php composer.phar require "apexwire/yii2-restclient"

or add

"apexwire/yii2-restclient": "*"

to the require section of your composer.json.

Configuration

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

    'components' => [
        'restclient' => [
            'class' => 'apexwire\restclient\Connection',
            'config' => [
                'base_uri' => 'https://api.site.com/',
            ],
        ],
    ],

Usage

Define your Model

class MyModel extends \apexwire\restclient\ActiveRecord
{
    public function attributes()
    {
        return ['id', 'name', 'status'];
    }
}

Debug

Connection example debug panel

$config['modules']['debug'] = [
    'class' => 'yii\debug\Module',
    'panels' => [
        'rest' => ['class' => 'apexwire\restclient\DebugPanel'],
    ],
];

License

This project is released under the terms of the BSD-3-Clause license. Read more here.

Copyright © 2016, ApexWire

Acknowledgments