PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Maik Greubel  >  Caribu ORM  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Readme
Class: Caribu ORM
Map objects to databases records using annotations
Author: By
Last change: Update README.md

Remove coveralls, use scrutinizer badge instead
Date: 4 years ago
Size: 3,054 bytes
 

Contents

Class file image Download

Build Status Code Coverage Scrutinizer Code Quality Dependency Status Codacy Badge

caribu

An annotation-based PHP Object Relational Mapper

This project aims to be an object relational mapper easy to use. The main target is to support developers writing only simple attribute containing classes and store it as entities into a database.

It has support for annotations so it is very flexible.

Here is a very basic example about the usage (for sqlite):

    CREATE TABLE super_duper_content (id INTEGER PRIMARY KEY, content TEXT);

    /SuperDuperEntity.php/
    
    /
     * @table super_duper_content
     */
    class SuperDuperEntity extends AbstractModel
    {
      /
       * @column id
       */
      private $sid;
      
      private $content;
      
      public function setSid($sid)
      {
        $this->sid = $sid;
      }
      
      public function getSid()
      {
        return $this->sid;
      }
      
      public function setContent($content)
      {
        $this->content = $content;
      }
      
      public function getContent()
      {
        return $this->content;
      }
    }

    /write-data-example.php/
    
    use \Nkey\Caribu\Orm\Orm;
    
    /First configure the ORM/
    Orm::configure(array(
      'type' => 'sqlite',
      'file' => ':memory:'
    ));
    
    // Create sqlite database table for memory storage
    // Orm::getInstance()->getConnection()->exec("CREATE TABLE super_duper_content (id INTEGER PRIMARY KEY, content TEXT)");
    
    /Now create a new entity and persist it to database/
    $entity = new SuperDuperEntity();
    $entity->setContent("Mega important content");
    $entity->persist();

    /read-data-example.php/
    
    /First read the entity from database/
    $entity = SuperDuperEntity::find(array('content' => "Mega important content"));
    
    /Display the content/
    echo $entity->getContent();

No need to write infrastructure and boilerblate code by yourself. Let the Orm do the hard work for you.

Caribu provides a convention-over-configuration behaviour by supporting annotations.

See the Wiki for more information about the capabilities and usage.


For more information send a message to info at phpclasses dot org.