PHP code example of webforge / doctrine-compiler

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

    

webforge / doctrine-compiler example snippets




namespace ACME\Blog\Entities;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User {

  /**
   * @ORM\Id 
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue
   */
  protected $id;

  /** 
   * @ORM\Column(length=200) 
   */
  protected $email;

  public function __construct($email) {
    $this->email = $email;
  }

  /**
   * @return string
   */
  public function getEmail() {
    return $this->email;
  }
  
  /**
   * @param string Email
   * @chainable
   */
  public function setEmail($email) {
    $this->email = $email;
    return $this;
  }
}




namespace ACME\Blog\Entities;

use Doctrine\ORM\Mapping as ORM;

abstract class CompiledUser {

  /**
   * @ORM\Id 
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue
   */
  protected $id;

  /** 
   * @ORM\Column(length=200) 
   */
  protected $email;

  public function __construct($email) {
    $this->email = $email;
  }

  /**
   * @return string
   */
  public function getEmail() {
    return $this->email;
  }
  
  /**
   * @param string Email
   * @chainable
   */
  public function setEmail($email) {
    $this->email = $email;
    return $this;
  }
}


namespace ACME\Blog\Entities;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
use Doctrine\ORM\Mapping as ORM;

class User extends CompiledUser {

  protected $somethingUserDefined;

  public function __construct($email, $somethingUserDefined) {
    parent::_construct($email);
    $this->somethingUserDefined = $somethingUserDefined;
  }
}