Skip to content
/ rapl Public

Doctrine-based EntityManager for REST APIs

License

Notifications You must be signed in to change notification settings

ademarco/rapl

Repository files navigation

What is RAPL?

RAPL (RESTful API Persistence Layer) is a RESTful variant of Doctrine's ORM. It implements the same interfaces, but allows you to store and retrieve entities from a remote (RESTful) API instead of from the database.

Why use RAPL?

  • RAPL abstracts the REST architecture, the HTTP protocol and the serialization of objects for you. All you have to do is to create your entity classes and to map them to the API (using mapping configuration).
  • If you are maintaining an API and you want to provide a client library for it, you can simply build it on top of RAPL.

Code Quality

Build Status Coverage Status Code Quality

Installation

RAPL can be installed using Composer:

composer require rapl/rapl

This will add RAPL to the dependency list of your main project's composer.json.

Setting up

<?php

require_once 'vendor/autoload.php';

$connection = new \RAPL\RAPL\Connection\Connection('http://example.com/api/');
$connection->addSubscriber(new \Your\Authentication\Subscriber());

$configuration = new \RAPL\RAPL\Configuration();
$paths         = array(__DIR__ . '/config');
$driver        = new \RAPL\RAPL\Mapping\Driver\YamlDriver($paths, '.rapl.yml');
$configuration->setMetadataDriver($driver);

$manager = new \RAPL\RAPL\EntityManager($connection, $configuration);

Usage

Once you have set everything up correctly, you can start using RAPL. This will feel very familiar if you have worked with Doctrine before.

$repository = $manager->getRepository('Your\Entity\Class');

// Get entity with id 3
$entity = $repository->find(3);

// Or get all of them
$entities = $repository->findAll();

About

Doctrine-based EntityManager for REST APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages