1. Go to this page and download the library: Download michaelking0/observers 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/ */
michaelking0 / observers example snippets
namespace ACME;
use MichaelKing0\Observers\Interfaces\ObservableInterface;
use MichaelKing0\Observers\Traits\ObservableTrait;
class MySubject implements ObservableInterface
{
use ObservableTrait;
}
namespace ACME;
use MichaelKing0\Observers\Interfaces\ObservableInterface;
use MichaelKing0\Observers\Traits\ObservableTrait;
class MySubject implements ObservableInterface
{
use ObservableTrait;
public function save()
{
$this->notify('SubjectSaved');
}
}
namespace ACME;
use MichaelKing0\Observers\Interfaces\ObservableInterface;
use MichaelKing0\Observers\Interfaces\ObserverInterface;
class MyObserver implements ObserverInterface
{
public function update($event, ObservableInterface $observable)
{
echo 'It works!';
}
}
$subject = new MySubject();
$subject->attach('SubjectSaved', new MyObserver());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.