PHPackages                             ucsf/restorm-bundle - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ucsf/restorm-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

ucsf/restorm-bundle
===================

REST-based ORM for Symfony - Obtain objects from a REST service... just like using an ORM

5.0.3(4y ago)1495↓100%MITPHPPHP &gt;=7.1.33

Since Oct 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ucsf-iam/UcsfRestOrm)[ Packagist](https://packagist.org/packages/ucsf/restorm-bundle)[ RSS](/packages/ucsf-restorm-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (17)Used By (0)

UcsfOrmOrm
==========

[](#ucsformorm)

(This document is a work in progress.)

A Symfony bundle that provides a Doctrine-based ORM over REST services

This bundle began as a need to connect Symfony applications with back-end REST services. Rather than duplicating [Guzzle](https://github.com/guzzle/guzzle) code across controller-injected services or making a complete new and custom library for them to share, I wanted to have bona fide entity managers, configured like a Doctrine entity manger, managing REST data. Rather than creating an actual Doctrine driver for REST (a possible retooling in the future) this bundle takes a middle approach by using Doctrine's facilities to emulate that sort of coupling. What you get are configurable entity managers with repositories, a managed way to initiate specific and detailed REST commands, and the ability to have REST data hydrate Symfony entities that are configured with Doctrine annotation. The configuration is fairly simple and though different from how Doctrine itself is configured it otherwise works fairly the same during application development.

Installation
------------

[](#installation)

- Add to composer.json
- `"ucsf/restorm": "dev-master"`
- Add the bundle to AppKernel.php
- `new Ucsf\LdapOrmBundle\UcsfRestOrmBundle()`
- Install using composer
- `$ composer install ucsf/restorm-bundle`

Documentation
-------------

[](#documentation)

### Develop with RestLdapOrm

[](#develop-with-restldaporm)

#### Configure a REST service in config.yml

[](#configure-a-rest-service-in-configyml)

```
ucsf_rest_orm:
    connections:
        foo_api:
            base_uri: %foo.base_uri%
            username: %foo.username%
            password: %foo.password%
    entity_managers:
        foo_api:
            # The connection and the entity_manager do not need to be named the same, but they
            # are so named here to show the convenience of matching them up. There can be multiple
            # entity_managers using the same connection.
            connection: foo_api
            repositories:
                NiceCompany\AwesomeBundle\Entity\Widget:
                    persist:
                        method: POST
                        path: widgets
                    all:
                        method: GET
                        path: widgets
                    find:
                      byId:
                          method: GET
                          path: widgets/{{id}}
                      byFactory:
                          method: GET
                          path: widgets?factory={{factoryId}}
                NiceCompany\AwesomeBundle\Entity\Factory:
                    find:
                      byId:
                          method: GET
                          path: factories/{{id}}
            # Commands do not have to copy repository method configuration, this just
            # shows command-based analogs of the repository examples.
            commands:
                get_all_widgets:
                    method: GET
                    path: widgets
                    class: NiceCompany\AwesomeBundle\Entity\Widget
                get_widget:
                    method: GET
                    path: widgets/{{id}}
                    class: NiceCompany\AwesomeBundle\Entity\Widget
                get_widget_by_factory:
                    method: GET
                    path: path: widgets?factory={{factoryId}}
                    class: NiceCompany\AwesomeBundle\Entity\Widget
                delete_widget:
                    # For this delete, there's no id supplied, but the object
                    # to delete itself as the body of the request. See how it's
                    # coded below
                    method: DELETE
                    path: widgets
                    class: NiceCompany\AwesomeBundle\Entity\Widget

```

#### Dependency injection for REST Entity Managers and Services

[](#dependency-injection-for-rest-entity-managers-and-services)

```
    widget_service:
        class: NiceCompany\AwesomeBundle\Services\WidgetService
        arguments:
            # Note how the entity manager's reference is built as
            #   'ucsf_rest_orm.'.$entityManagerName.'_entity_manager'
            entityManager: "@ucsf_rest_orm.foo_api_entity_manager"

```

#### Creating Entities (usually to represent an object class)

[](#creating-entities-usually-to-represent-an-object-class)

It works pretty much as Doctrine entities that are generated from a real SQL database. I have not experimented with much more of the Doctrine annotation than what you see here.

```
/**
 * @ORM\Table(name="widget")
 * @ORM\Entity
 */
class Widget {

    /**
     * @var integer
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     */
    private $id;

    /**
     * @var string
     * @ORM\Column(name="widgetName", type="string")
     */
    private $widgetName;

    ...

```

#### Coding the Service

[](#coding-the-service)

Once you get to this point, it's pretty much just like any other Doctrine entity manager.

```
use UCSF\RestOrmBundle\Doctrine\ORM\EntityManager;
use NiceCompany\AwesomeBundle\Entity\Widget;
use NiceCompany\AwesomeBundle\Entity\Factory;

class WidgetService
{
    private $entityManager;
    private $widgetRepository;

    public function __construct(EntityManager $entityManager) {
        $this->entityManager = $entityManager;
        $this->widgetRepository = $entityManager->getRepository(Widget::class);
        $this->factoryRepository = $entityManager->getRepository(Factory::class);
    }

    // Using repositories

    public function getWidgetById($id) {
        return $this->roleRepository->findById($id);
    }

    public function saveWidget(Widget $widget) {
        return $this->entityManager->persist($widget);
    }

    // Using commands

    public function getWidgetsByFactory($widgetId) {
        return $this->entityManager->command('get_widgets_by_factory', ['widgetId' => $widgetId]);
    }

    public function deleteWidget(Widget $widget) {
        return $this->entityManager->command('delete_widget', [] /* null is fine too */, $widget);
    }

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~123 days

Recently: every ~354 days

Total

16

Last Release

1660d ago

Major Versions

1.2.1 → 2.0.02017-06-24

2.1.0 → 5.0.02017-12-04

PHP version history (3 changes)1.0.0PHP &gt;=5.6

1.2.1PHP &gt;=5.6.14

5.0.1PHP &gt;=7.1.33

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f4826478f5352853cb7cb3b0687d7ead572cae57a7d0c539ac99b7ca21581e7?d=identicon)[ucsf-iam](/maintainers/ucsf-iam)

---

Top Contributors

[![jasongabler](https://avatars.githubusercontent.com/u/1828132?v=4)](https://github.com/jasongabler "jasongabler (15 commits)")

---

Tags

restormucsf

### Embed Badge

![Health badge](/badges/ucsf-restorm-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ucsf-restorm-bundle/health.svg)](https://phpackages.com/packages/ucsf-restorm-bundle)
```

###  Alternatives

[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[ory/hydra-client

Documentation for all of Ory Hydra's APIs.

17435.9k](/packages/ory-hydra-client)[rizeway/orem

Rizeway OREM is a Restful API Abstraction Layer. It is to Restful APIs what doctrine is for databases.

266.1k](/packages/rizeway-orem)[whatarmy/fedex-rest

New FedEx Rest API wrapper

2440.5k1](/packages/whatarmy-fedex-rest)

PHPackages © 2026

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