PHP code example of rizeway / orem

1. Go to this page and download the library: Download rizeway/orem library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rizeway / orem example snippets




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++;
    }
}

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

$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