PHP code example of gpslab / payload
1. Go to this page and download the library: Download gpslab/payload 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/ */
gpslab / payload example snippets
class SimpleMessage extends PayloadMessage
{
public $id = 0;
public $name = '';
}
$message = new SimpleMessage([
'id' => 123,
'name' => 'foo',
]);
$message->id; // 123
$message->name; // foo
$message->payload(); // ['id' => 123, 'name' => 'foo']
class SimpleMessage extends PayloadMessage
{
protected $id = 0;
protected $name = '';
public function id()
{
return $this->id;
}
public function name()
{
return $this->name;
}
}
$message = new SimpleMessage([
'id' => 123,
'name' => 'foo',
]);
$message->id(); // 123
$message->name(); // foo
$message->payload(); // ['id' => 123, 'name' => 'foo']
class SimpleMessage extends PayloadMessage
{
private $id = 0;
private $name = '';
public function id(): integer
{
return $this->id;
}
protected function setId(integer $id)
{
$this->id = $id;
}
public function name(): string
{
return $this->name;
}
protected function setName(string $name)
{
$this->name = $name;
}
}
$message = new SimpleMessage([
'id' => 123,
'name' => 'foo',
]);
$message->id(); // 123
$message->name(); // foo
$message->payload(); // ['id' => 123, 'name' => 'foo']
class RenameContactCommand extends PayloadCommand
{
public $contact_id = 0;
public $new_name = '';
}
class ContactByIdentityQuery extends PayloadQuery
{
public $id = 0;
}
class RenamedContactEvent extends PayloadDomainEvent
{
public $contact_id = 0;
public $old_name = '';
public $new_name = '';
}