1. Go to this page and download the library: Download xb/observer 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/ */
xb / observer example snippets
use xb\observer\Subject as ObSubject;
$subject = new ObSubject;
$mail = __NAMESPACE__ . '\\observer\\Mail';
$push = __NAMESPACE__ . '\\observer\\Push';
$sms = __NAMESPACE__ . '\\observer\\Sms';
$subject->bind('mail', function () {
return [
'rec' => '[email protected]',
'title' => 'test mail',
];
});
$subject->bind('push', function () {
return [
'lawer' => new \StdClass,
'leader' => new \StdClass,
];
});
$subject->bind('sms', function () {
return [
'phone' => 'xxxxxxxx',
'content' => 'test sms',
];
});
$subject->bind('common', function () {
return new \ArrayObject;
});
$subject->attach(new $mail);
$subject->attach(new $push);
$subject->attach(new $sms);
$subject->notify();
use xb\observer\Server as ObServer;
class MailObserver extends ObServer {
public function doTask($subject) {
echo '<pre>';
print_r($subject->mail);
echo '</pre>';
echo '<pre>';
print_r($subject->common);
echo '</pre>';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.