rizeway/orem 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rizeway/orem

Composer 安装命令:

composer require rizeway/orem

包简介

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

README 文档

README

Build Status

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

Getting Started

Say you have the following JSON HTTP API to make CRUD on an object named "status"

GET /status # Return a list of statuses
GET /status/1 # Return the status of id 1
POST /status # Create a status (the body of the request contain the hash of the status)
PUT /status/1 # Update the status of id 1 (the body of the request contain the hash of the status)
DELETE /status/1 # Delete the status of id 1

1- Create a folder to store your mappings.

2- Create a mapping file in this folder. The mapping file sould be named status.orem.yml and will look like this.

class: MyNamespace/Status
fields:
    id:
        primaryKey: true
    message:
        type: string
    author:
        type: string
    count_likes
        type: integer    

3- Create a simple entity class

<?php

namespace MyNamespace 

class Status 
{
    protected $id;
    protected $message;
    protected $author;
    protected $count_likes = 0;

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

    public function getMessage()
    {
        return $this->message;
    }

    public function setMessage($message)
    {
        $this->message = $message;
    }

    public function getAuthor()
    {
        return $this->author;
    }

    public function setAuthor($author)
    {
        $this->author = $author;
    }

    public function getCountLikes()
    {
        return $this->count_likes;
    }

    public function addLike()
    {
        $this->count_likes++;
    }
}

4- Get an OREM Manager

$factory = new \Rizeway\OREM\Config\Factory($directory, $apiBaseUrl);
$manager = $factory->getManager();

5- How to use the manager to make api calls

$status = new \MyNamespace\Status();
$status->setMessage('my message');
$status->setAuthor('author');
$manager->persist($status); // Call POST API

$status->addLike();
$manager->update($status); // Call PUT API

$manager->remove($status); // Call DELETE API

$statuses = $manager->getRepository('status')->findAll(); // Call GET api and return an array of \MyNamespace\Status

$status = $manager->getRepository('status')->find(1); // GET api with primary key, return an object \MyNamespace\Status

Installation

Install using composer

{
    "require": {
        "rizeway/orem": "0.1.*@dev"
    }
}

Roadmap

  • Url Customisation
  • Handling HasMany and HasOne lazy loading
  • Handling Cascade Delete And Options to disable Cascade update
  • Custom api functions
  • More Field Types
  • Extra parameters in URL (like CAS ticket or Other auth token)

Contribute

Install the dependencies using composer and you're ready to go

git clone https://github.com/youknowriad/OREM.git && cd OREM
curl -s http://getcomposer.org/installer | php
./composer.phar install --dev

Tests

OREM is tested using atoum

./bin/atoum --test-all

统计信息

  • 总下载量: 6.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-04-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固