1. Go to this page and download the library: Download neat/event 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/ */
neat / event example snippets
// First create your container (used for event dispatching and dependency injection)
$container = new Neat\Service\Container();
// The dispatcher will need a service container for dependency injection
$dispatcher = new Neat\Event\Dispatcher($container);
// A generic event can be defined using a simple PHP class without any members
class SomeEvent
{
}
// Specific events may also use inheritance using extends or interfaces
class SomeSpecificEvent extends SomeEvent
{
}
// Implement the Stoppable event interface if you want control over dispatching your event
class SomeStoppableEvent implements Neat\Event\Stoppable
{
public function isPropagationStopped(): bool
{
return random_int(0, 1) == 1;
}
}
// Now listen for events of this class or any of its subclasses or implementations
$dispatcher->listen(SomeEvent::class, function (SomeEvent $event) {
// ...
});
// Or for a specific event
$dispatcher->listen(SomeSpecificEvent::class, function (SomeSpecificEvent $event) {
// ...
});
// This will trigger only the SomeEvent listener, NOT the SomeSpecificEvent listener
$dispatcher->dispatch(new SomeEvent());
// This will trigger both the SomeEvent and SomeSpecificEvent listeners
$dispatcher->dispatch(new SomeSpecificEvent());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.