1. Go to this page and download the library: Download carloswph/gazer 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/ */
carloswph / gazer example snippets
use Gazer\Subject;
use Gazer\Gazer;
A extends Subject {
}
// This is one observer - but you could use the same logic
// for more observers, like classes C or D, for instance
class B extends Gazer {
}
$a = new A();
$b = new B();
// Now, all we need to do for B to "observer" A
// is using the method attach() from A
$a->attach($b);
// Ready! If A uses the method notify(), then a method
// update() in B will be ran, and B gets the A object
// held in the variable $subject, thus...
$a->notify(); // B gets A object immediately
use Gazer\Subject;
use Gazer\Gazer;
$example = 'Observed';
public function __construct() {
echo "Subject\n";
}
}
class B extends Gazer {
public function info() {
echo $this->subject->example;
}
}
$a = new A();
$b = new B();
// The only thing you can see is the word "Subject" echoed
// But now, let's put B to observe A
$a->attach($b);
$a->notify();
// As B is observing and A has notified all observers, so
// now we can manipulate the A object, which has been updated
// and held in the property $subject of B
$b->info(); // Prints "Observed"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.