PHPackages                             bankiru/doctrine-api-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. [Database &amp; ORM](/categories/database)
4. /
5. bankiru/doctrine-api-client

AbandonedLibrary[Database &amp; ORM](/categories/database)

bankiru/doctrine-api-client
===========================

Doctrine-faced RPC API Client

2.0(8y ago)928.8k1[4 issues](https://github.com/bankiru/doctrine-api-client/issues)[1 PRs](https://github.com/bankiru/doctrine-api-client/pulls)1MITPHPPHP ~5.5|~7.0

Since Apr 18Pushed 3y ago4 watchersCompare

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

READMEChangelog (3)Dependencies (10)Versions (9)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/da5b7650cd4779ea3605d598e13938ebb62261958799fc6afdd92c3616b87973/68747470733a2f2f706f7365722e707567782e6f72672f62616e6b6972752f646f637472696e652d6170692d636c69656e742f762f737461626c65)](https://packagist.org/packages/bankiru/doctrine-api-client)[![Total Downloads](https://camo.githubusercontent.com/2637d26a3c3a2d807c6b039966d260a9e895987d96602c9f0422cab5b660b900/68747470733a2f2f706f7365722e707567782e6f72672f62616e6b6972752f646f637472696e652d6170692d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/bankiru/doctrine-api-client)[![Latest Unstable Version](https://camo.githubusercontent.com/9b5d5deb022308db114aacf8310933260a148135fd00d05d587365b4dafb5a17/68747470733a2f2f706f7365722e707567782e6f72672f62616e6b6972752f646f637472696e652d6170692d636c69656e742f762f756e737461626c65)](https://packagist.org/packages/bankiru/doctrine-api-client)[![License](https://camo.githubusercontent.com/b04df12ba63fdd0f7bdbe204183ce4eb27a195c61ca185f1550129b90111d2b7/68747470733a2f2f706f7365722e707567782e6f72672f62616e6b6972752f646f637472696e652d6170692d636c69656e742f6c6963656e7365)](https://packagist.org/packages/bankiru/doctrine-api-client)

[![Build Status](https://camo.githubusercontent.com/0ce94689908e1fcfb5b04458ad944aeb284f9e98e739ef9bf9d2960ac9c1e848/68747470733a2f2f7472617669732d63692e6f72672f62616e6b6972752f646f637472696e652d6170692d636c69656e742e737667)](https://travis-ci.org/bankiru/doctrine-api-client?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/70d897766ee2fd24628aa2fbdfe6b997851663247508c73416dc6a9c88e8b3ab/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62616e6b6972752f646f637472696e652d6170692d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/bankiru/doctrine-api-client/)[![Code Coverage](https://camo.githubusercontent.com/d6c0100bff26ed478f7a58e8d9e00059e9237c4928decadf887c40b76be86222/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62616e6b6972752f646f637472696e652d6170692d636c69656e742f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/bankiru/doctrine-api-client/)[![SensioLabsInsight](https://camo.githubusercontent.com/51b5104cfb63054de7f946fc4977d308cb359c32602dbb8f1ac6548871a1593e/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f32633166356334312d383664652d343434312d393837362d6230656530356430313261662f6d696e692e706e67)](https://insight.sensiolabs.com/projects/2c1f5c41-86de-4441-9876-b0ee05d012af)

Doctrine-faced RPC Client
=========================

[](#doctrine-faced-rpc-client)

Implementation of `doctrine\common` interfaces with RPC interfaces (`scaytrase\rpc-common`)

Usage
-----

[](#usage)

```
class \MyVendor\Api\Entity\MyEntity {
    /** @var string */
    private $id;
    /** @var string */
    private $payload;

    public function getId() { return $this->id; }

    public function getPayload() { return $this->payload; }
}

```

`Resources/config/api/MyEntity.api.yml` content:

```
MyVendor\Api\Entity\MyEntity:
  type: entity
  id:
    id:
      type: int

  fields:
    payload:
      type: string

  client:
    name: my-client
    entityPath: my-entity
```

Configure `EntityManager`

```
class RpcClient implements RpcClientInterface {
    /** RpcClient impl */
}

$client = new RpcClient();

$registry = new ClientRegistry();
$registry->add('my-client', $client);

$configuration = new Configuration();
$configuration->setMetadataFactory(new EntityMetadataFactory());
$configuration->setRegistry($this->registry);
$configuration->setProxyDir(CACHE_DIR . '/doctrine/proxy/');
$configuration->setProxyNamespace('MyVendor\Api\Proxy');
$driver = new MappingDriverChain();
$driver->addDriver(
    new YmlMetadataDriver(
        new SymfonyFileLocator(
            [
                __DIR__ . '/../Resources/config/api/' => 'MyVendor\Api\Entity',
            ],
            '.api.yml',
            DIRECTORY_SEPARATOR)
    ),
    'MyVendor\Api\Entity'
);
$configuration->setDriver($driver);

$manager = new EntityManager($configuration);
```

Call entity-manager to retrieve entities through your api

```
$samples = $manager->getRepository(\MyVendor\Api\Entity\MyEntity::class)->findBy(['payload'=>'sample']);
foreach ($samples as $sample) {
   var_dump($sample->getId());
}
```

References
----------

[](#references)

You could reference other API entities via relation annotations. General bi-directional self-reference relation below:

```
MyVendor\Api\Entity\MyEntity:
  type: entity
  id:
    id:
      type: int

  fields:
    payload:
      type: string

  manyToOne:
    parent:
        target: MyVendor\Api\Entity\MyEntity
        inversedBy: children
  oneToMany:
    children:
        target: MyVendor\Api\Entity\MyEntity
        mappedBy: parent
```

In order to make `*toMany` relations works flawlessly you should define the mapped class property as `Entity[]|ArrayCollection` as hydrator will substitute your relation property with lazy-loading collection interface.

### Note on lazy-loading

[](#note-on-lazy-loading)

Generic API is not a DB, so eager reference pre-fetching will always result in additional API query (excluding super-APIs with prefetching features, not supported now), so current implementation always assumes that all requests are extra-lazy. This means that no data will be fetched until you really need it, and you'll have only lazy proxy object before that happens.

Keep it in the mind

Hacking into fetching process
-----------------------------

[](#hacking-into-fetching-process)

### Custom repository

[](#custom-repository)

Just call defined RpcClient from your repository

```
class MyRepository extends \Bankiru\Api\Doctrine\EntityRepository
{
    public function callCustomRpcMethod()
    {
        $request = new \Bankiru\Api\Rpc\RpcRequest('my-method',['param1'=>'value1']);
        $data = $this->getClient()->invoke([$request])->getResponse($request);

        return $data;
    }
}
```

Or more portable with mapping

```
MyVendor\Api\Entity\MyEntity:
  type: entity
  id:
    id:
      type: int

  fields:
    payload:
      type: string

  repositoryClass: MyVendor\Api\Repository\MyRepository # This will override repository for MyEntity
  api:
    factory: Vendor\Api\CrudsApiFactory

  client:
    name: my-client
    # entityPath: my-entity autoconfigures find and search methods for you as following, but it is not overridable
    # You can also specify path separator as
    # entityPathSeparator: "-"
    # To make autogenerated methods look like my-entity-find
    methods:
        find: my-entity\find      # find method is mandatory to find calls work
        search: my-entity\search  # find method is mandatory to findBy calls work
        custom: my-custom-method  # do some custom stuff
```

```
class MyRepository extends \Bankiru\Api\Doctrine\EntityRepository
{
    public function callCustomRpcMethod()
    {
        $request = new \Bankiru\Api\Rpc\RpcRequest(
            $this->getClientMethod('custom'),
            ['param1'=>'value1']
        );
        $data = $this->getClient()->invoke([$request])->getResponse($request);

        return $data;
    }
}
```

### Custom Cruds API

[](#custom-cruds-api)

### Custom field types

[](#custom-field-types)

You could register additional field types to configuration `TypeRegistry` (`Configuration::getTypeRegistry()`). Just implement the `Type` and register it via `TypeRegistry::add('alias', $type)`. Doctrine ORM types are simple transformers with no real dependencies available but for this implementation we gone a bit further and make the types DI capable, so you can register any instance of `Type` as type, so it could be DI-enabled service, with any logic you need

### TBD

[](#tbd)

- No embeddables

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance11

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% 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.

###  Release Activity

Cadence

Every ~77 days

Total

6

Last Release

3284d ago

Major Versions

1.x-dev → 2.02017-05-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed906771163ff68cfb365bdd3b8278a3ce1b464f94051ff7ab50c03a30110efe?d=identicon)[scaytrase](/maintainers/scaytrase)

---

Top Contributors

[![scaytrase](https://avatars.githubusercontent.com/u/6578413?v=4)](https://github.com/scaytrase "scaytrase (16 commits)")[![hanovruslan](https://avatars.githubusercontent.com/u/1153520?v=4)](https://github.com/hanovruslan "hanovruslan (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

apiclientdoctrinerpc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bankiru-doctrine-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/bankiru-doctrine-api-client/health.svg)](https://phpackages.com/packages/bankiru-doctrine-api-client)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M151](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

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