1. Go to this page and download the library: Download ice-cream/events 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/ */
ice-cream / events example snippets
// Create the handler:
$eventHandler = new EventHandler();
// Create a listener to listen to events being fired:
$listener = new Listener();
use IceCreamEvents\Listener;
class PageViewEventListener extends Listener{
// Read on to see the event definition.
public function onAction(PageViewEvent $pageViewedEvent) {
// ... Do something.
}
}
use IceCreamEvents\Event;
class PageViewEvent extends Event {
protected $pageViewed;
public function __construct(PageViewed $pageViewed) {
$this->pageViewed = $pageViewed;
}
public function getPageViewed() {
return $this->pageViewed;
}
}