Tools to use API as ActiveRecord for Yii2
Use your API as ActiveRecord
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.
To use this extension, configure restclient component in your application config:
'components' => [
'restclient' => [
'class' => 'apexwire\restclient\Connection',
'config' => [
'base_uri' => 'https://api.site.com/',
],
],
],
Define your Model
class MyModel extends \apexwire\restclient\ActiveRecord
{
public function attributes()
{
return ['id', 'name', 'status'];
}
}
Connection example debug panel
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
'panels' => [
'rest' => ['class' => 'apexwire\restclient\DebugPanel'],
],
];
This project is released under the terms of the BSD-3-Clause license. Read more here.
Copyright © 2016, ApexWire
- This project is based on Yii2 HiArt.