1. Go to this page and download the library: Download josephlavin/local-eventing 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/ */
josephlavin / local-eventing example snippets
use josephlavin\localEventing\LocalEventing;
class dummy
{
use LocalEventing;
public function save()
{
// do your saving logic...
$this->fireLocalEvent('saved');
}
protected function __onLocalEvent_saved_send_notification()
{
// Logic here to send notification...
}
protected function __onLocalEvent_saved_log_event()
{
// Logic for logging here...
}
}
class BaseModel
{
use LocalEventing;
public function __construct()
{
$this->fireLocalEvent('created');
}
public function insert()
{
$this->fireLocalEvent('preInsert');
// the insert logic...
$this->fireLocalEvent('postInsert');
}
}
trait UuidPrimaryKey
{
// reminder that we must also use LocalEventing Trait
abstract protected function _ key here...
}
}
class MyModel extends BaseModel
{
use UuidPrimaryKey;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.