PHP code example of rossriley / doctrine-entity-base

1. Go to this page and download the library: Download rossriley/doctrine-entity-base 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/ */

    

rossriley / doctrine-entity-base example snippets


$object = new Myentity();
$object->option1 = 'test';
echo $object->option1; // 'test'


$object = new Myentity();
$object->setOption1('test');
echo $object->getOption1(); // 'test'


$object = new Myentity();
$object->setOption1('test');
print_r($object->serialize()); // ['option1'=>'test', 'option2'=>'']




namespace Myproject;

use Doctrine\Entity\Base;

class Myentity extends Base
{
    protected $option1;
    protected $option2;
    
    
    public function setOption1($val)
    {
        $this->option1 = json_encode($val);
    }
    
    public function getOption1()
    {
        return json_decode($val);
    }
    
    public function serializeOption1()
    {
        return json_decode($val);
    }
    
}