1. Go to this page and download the library: Download angrybytes/domainobject 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/ */
angrybytes / domainobject example snippets
class Person
{
public $name;
}
class Person
{
public $firstName;
public $lastName;
public function getFullName()
{
return $this->firstName . ' ' . $this->lastName;
}
}
use Angrybytes\DomainObject;
use \InvalidArgumentException;
class BlogPost extends DomainObject
{
private $title;
private $contents;
public function getTitle()
{
return $this->title;
}
public function setTitle($title)
{
// You can do simple sanity checks in your setters
if (strlen($title) < 3) {
throw new InvalidArgumentException('Title should be 3 or more characters long');
}
$this->title = $title;
return $this;
}
public function getContents()
{
return $this->contents;
}
public function setContents($contents)
{
$this->contents = $contents;
return $this;
}
}
$post = new BlogPost;
// Set properties
$post
->setTitle('This is the title for my blog post')
->setContents('foo');
// Retrieve properties using property notation
echo $post->title;
echo $post->contents;
// Retrieve data in array form for easy serialization
$json = json_encode(
$post->toArray()
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.