{"id":21373038,"url":"https://github.com/hiqdev/yii2-hiart","last_synced_at":"2025-04-09T17:26:48.162Z","repository":{"id":45656361,"uuid":"36179969","full_name":"hiqdev/yii2-hiart","owner":"hiqdev","description":"ActiveRecord for API","archived":false,"fork":false,"pushed_at":"2024-06-14T11:08:24.000Z","size":425,"stargazers_count":58,"open_issues_count":3,"forks_count":14,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-02T10:48:31.845Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiqdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-24T15:56:47.000Z","updated_at":"2024-06-26T18:29:15.000Z","dependencies_parsed_at":"2022-09-06T07:11:12.805Z","dependency_job_id":"57de2e47-bd5b-4563-8549-93cfcc81ff2c","html_url":"https://github.com/hiqdev/yii2-hiart","commit_stats":{"total_commits":351,"total_committers":9,"mean_commits":39.0,"dds":0.3931623931623932,"last_synced_commit":"3246c3d11099edf5c5490074b352f29949216fcb"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiqdev%2Fyii2-hiart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiqdev%2Fyii2-hiart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiqdev%2Fyii2-hiart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiqdev%2Fyii2-hiart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiqdev","download_url":"https://codeload.github.com/hiqdev/yii2-hiart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248076310,"owners_count":21043747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-11-22T08:24:48.850Z","updated_at":"2025-04-09T17:26:48.137Z","avatar_url":"https://github.com/hiqdev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HiArt\n\n**ActiveRecord for API**\n\n[![Latest Stable Version](https://poser.pugx.org/hiqdev/yii2-hiart/v/stable)](https://packagist.org/packages/hiqdev/yii2-hiart)\n[![Total Downloads](https://poser.pugx.org/hiqdev/yii2-hiart/downloads)](https://packagist.org/packages/hiqdev/yii2-hiart)\n[![Build Status](https://img.shields.io/travis/hiqdev/yii2-hiart.svg)](https://travis-ci.org/hiqdev/yii2-hiart)\n[![Scrutinizer Code Coverage](https://img.shields.io/scrutinizer/coverage/g/hiqdev/yii2-hiart.svg)](https://scrutinizer-ci.com/g/hiqdev/yii2-hiart/)\n[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/hiqdev/yii2-hiart.svg)](https://scrutinizer-ci.com/g/hiqdev/yii2-hiart/)\n[![Dependency Status](https://www.versioneye.com/php/hiqdev:yii2-hiart/dev-master/badge.svg)](https://www.versioneye.com/php/hiqdev:yii2-hiart/dev-master)\n\nThis Yii2 extension provides [ActiveRecord](http://en.wikipedia.org/wiki/Active_record_pattern)\nimplementation that allows to access remote/web API same way as you do with normal\n[Yii2 DB ActiveRecord](http://www.yiiframework.com/doc-2.0/guide-db-active-record.html).\n\n## Installation\n\nThe preferred way to install this yii2-extension is through [composer](http://getcomposer.org/download/).\n\n```sh\ncomposer require \"hiqdev/yii2-hiart\"\n```\n\nBut if you prefer [Guzzle] transport use `yii2-hiart-guzzle` package:\n\n```sh\ncomposer require \"hiqdev/yii2-hiart-guzzle\"\n```\n\n## Configuration\n\nTo use this extension, configure hiart component in your application config:\n\n```php\n    'components' =\u003e [\n        'hiart' =\u003e [\n            'class' =\u003e \\hiqdev\\hiart\\rest\\Connection::class,\n            'requestClass' =\u003e \\hiqdev\\hiart\\auto\\Request::class,\n            'baseUri' =\u003e 'https://site.com/api/v3/',\n        ],\n    ],\n```\n\nNote three main options:\n\n- `class` specifies class that actually implements API to be accessed, **REST** in this case\n- `requestClass` specifies transport implementation to be used, **auto** in this case\n- `baseUri` specifies starting point of the API\n\n### Transports\n\nAvailable transports are:\n\n- **auto** - autodetects best supported transport\n- [PHP streams], the most generic fallback, included in this package\n- [cURL], included in this package\n- [Guzzle], provided with [yii2-hiart-guzzle](https://github.com/hiqdev/yii2-hiart-guzzle)\n- [yii2-httpclient], provided with [yii2-hiart-httpclient](https://github.com/hiqdev/yii2-hiart-httpclient)\n\n[PHP streams]:      http://php.net/manual/en/book.stream.php\n[cURL]:             http://php.net/manual/en/book.curl.php\n[Guzzle]:           https://github.com/guzzle/guzzle\n[yii2-httpclient]:  https://github.com/yiisoft/yii2-httpclient\n\nYou can implement your own transport.\nAll you need is to create two classes: `Request` and `Response`, it's not difficult see available implementations.\nTransport can be even non-HTTP based.\n\n### Query builders\n\nQueryBuilder is what actually implements an API.\n\nWe are developing `QueryBuilder`s for:\n\n- Basic [REST API](https://en.wikipedia.org/wiki/Representational_state_transfer), included in this package\n- [GitHub API](https://developer.github.com/v3/), provided with [yii2-hiart-github](https://github.com/hiqdev/yii2-hiart-github)\n- [HiPanel API](https://hipanel.com/), provided with [hipanel-hiart](https://github.com/hiqdev/hipanel-hiart)\n\nYou can implement your own API.\nBasically all you need is create your `QueryBuilder` class with these methods:\n\n- `buildMethod(Query $query)`\n- `buildHeaders(Query $query)`\n- `buildUri(Query $query)`\n- `buildQueryParams(Query $query)`\n- `buildBody(Query $query)`\n- `buildFormParams(Query $query)`\n\nSee available implementations and ask questions using issues on GitHub.\n\n## Usage\n\nDefine your Model:\n\n```php\nclass User extends \\hiqdev\\hiart\\ActiveRecord\n{\n    public function rules()\n    {\n        return [\n            ['id', 'integer', 'min' =\u003e 1],\n            ['login', 'string', 'min' =\u003e 2, 'max' =\u003e 32],\n        ];\n    }\n}\n```\n\nNote that you use general `hiqdev\\hiart\\ActiveRecord` class not specific for certain API.\nAPI is specified in connection options and you don't need to change model classes when\nyou change API.\n\nThen you just use your models same way as DB ActiveRecord models.\n\n```php\n$user = new User();\n$user-\u003elogin = 'sol';\n\n$user-\u003esave();\n\n$admins = User::find()-\u003ewhere(['type' =\u003e User::ADMIN_TYPE])-\u003eall();\n```\n\nBasically all the features of [Yii2 ActiveRecord] work if your API provides them.\n\n[Yii2 ActiveRecord]: http://www.yiiframework.com/doc-2.0/guide-db-active-record.html\n\n## License\n\nThis project is released under the terms of the BSD-3-Clause [license](LICENSE).\nRead more [here](http://choosealicense.com/licenses/bsd-3-clause).\n\nCopyright © 2015-2018, HiQDev (http://hiqdev.com/)\n\n## Acknowledgments\n\n- This project was started as fork from [Yii2 Elasticsearch](https://github.com/yiisoft/yii2-elasticsearch).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiqdev%2Fyii2-hiart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiqdev%2Fyii2-hiart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiqdev%2Fyii2-hiart/lists"}