PHPackages                             dimvic/yiiyin - 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. [API Development](/categories/api)
4. /
5. dimvic/yiiyin

AbandonedArchivedYii-module[API Development](/categories/api)

dimvic/yiiyin
=============

Yii 1.1 json:api module

248PHP

Since May 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/dimvic/yii-yin)[ Packagist](https://packagist.org/packages/dimvic/yiiyin)[ RSS](/packages/dimvic-yiiyin/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

json:api module for Yii 1.1
===========================

[](#jsonapi-module-for-yii-11)

[![Packagist package](https://camo.githubusercontent.com/91af0539e6a0168e39ebcd03eeadcd543a91f72a96b73febd569578ccebdfa67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d6465762d6c69676874677265792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dimvic/yiiyin)[![License](https://camo.githubusercontent.com/341ba1518057cda89c0ba6f96a14c5bf121fc9e635b980100c0471ade953c6ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64696d7669632f79696979696e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Yii 1.1 module, drop in and configure to automagically expose resources (CActiveRecord models) through a [json:api](http://jsonapi.org) 1.0 compatible web service.

Thanks [yin](https://github.com/woohoolabs/yin) for being an amazing library and providing the example this module is heavily based on.

Thanks [Máté Kocsis](https://github.com/kocsismate) for the help and merging of the pull requests.

Supported functions
-------------------

[](#supported-functions)

- GET /{type}/{id}
- GET /{type}/{id}/relationships/{relationship}
- GET /{type}/{id}/{relationship}
- PATCH /{type}/{id}
- POST /{type}
- DELETE /{type}/{id}

Usage
-----

[](#usage)

Simply configure the module and you have a fully functional HATEOAS web service for your models.

I like to believe configuration is self-explanatory, the only thing you should watch out for is that you need to configure a type (even with an active methods array) for each exposed relationship type:

```
return [
    ...
   'modules' => [
        'yiiyin' => [
            'route' => 'api',//expose the module at /api
            'controllerMap' => [//only add this if you want all requests logged
                'default'=> [
                    'class'=>'dimvic\\YiiYin\\ApiLogController',//log using Yii::log($log, 'info', 'json:api')
                ],
            ],
            'resources' => [
                'Book' => [//exposed model
                    'type' => 'books',//exposed at api/books
                    'methods' => ['GET', 'POST', 'PATCH', 'DELETE'],//API methods supported for this model
                    'exposedRelationships' => [//all relations a client may access using the API
                        'book_i18ns' => 'book_i18ns',//relation name => API type (route)
                        'authors' => 'authors',
                        'publisher' => 'publishers',
                    ],
                    'defaultRelationships' => [//all relations a client may access using the API
                        'book_i18ns' => 'book_i18ns',//relation name => API type (route)
                        'authors' => 'authors',
                        'publisher' => 'publishers',
                    ],
                ],
                'BookI18n' => [
                    'type' => 'book_i18ns',
                    'methods' => ['GET', 'POST', 'PATCH'],
                ],
                'Author' => [
                    'type' => 'authors',
                    'methods' => ['GET', 'POST', 'PATCH'],
                ],
                'Publisher' => [
                    'type' => 'publishers',
                    'methods' => ['GET', 'POST', 'PATCH'],
                    'exposedRelationships' => ['representatives' => 'representatives'],
                    'defaultRelationships' => ['representatives' => 'representatives'],
                ],
                'Representative' => [
                    'type' => 'representatives',
                    'methods' => ['GET', 'POST', 'PATCH'],
                ],
            ],
        ],
        ...
    ],
    ...
    'components' => [
        'urlManager' => [
            'urlFormat' => 'path',
            'showScriptName' => false,
            'rules' => [
                ['class' => 'dimvic\\YiiYin\\ApiUrlRule'],
                ...
            ],
        ],
    ],
    ....
];
```

Demo
----

[](#demo)

Example project can be found [here](https://github.com/dimvic/yii-yin-example). Setup it up in less than a minute.

TODO
----

[](#todo)

- Fix `PATCH {"relationship": {"data":null}}`
- GET `/{resource}` paginated
- GET `?include` &amp; eager loading for included relationships
- GET `?filter`
- Review error codes &amp; messages
- Controller filter to validate requests (see [yin-middlewares](https://github.com/woohoolabs/yin-middlewares))
- UUID generator for exposed models (using a behavior)
- Allow use customized of customized repositories, transformers and hydrators

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/70f09cf662c407690fe7f5d05fb2b73b1a51da1d5d4ca576920204f29736d4b1?d=identicon)[dimvic](/maintainers/dimvic)

---

Top Contributors

[![dimvic](https://avatars.githubusercontent.com/u/386233?v=4)](https://github.com/dimvic "dimvic (17 commits)")

### Embed Badge

![Health badge](/badges/dimvic-yiiyin/health.svg)

```
[![Health](https://phpackages.com/badges/dimvic-yiiyin/health.svg)](https://phpackages.com/packages/dimvic-yiiyin)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
