1. Go to this page and download the library: Download hackpack/hacktions 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/ */
hackpack / hacktions example snippets
class MyEmitter
{
use EventEmitter;
}
$emitter = new MyEmitter();
//listeners all use variable argument signatures
$lambda = (...) ==> print(func_get_args()[0]);
$emitter->on('myevent', $lambda);
//trigger fires all registered events with the given name - can take variable arguments
$emitter->trigger('myevent', 'brian');
$emitter->off('myevent', $lambda); //remove a single listener
$emitter->removeListeners(); //remove all listeners
$emitter->removeListeners('myevent') //remove all 'myevent' events
class Cook
{
//Cook notifies Waiter objects
use Subject<Waiter>;
protected Vector<Burger> $cookedBurgers = {};
public function cook(Burger $burger): void
{
$this->cookedBurgers->add($burger);
$this->notifyObservers();
}
//implement methods to work on cooked items...
}
class Waiter implements Observer<Cook>
{
//Waiter observes a cook
public function update(Cook $cook, ...): void
{
$burger = $cook->orderUp();
//deliver burger...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.