1. Go to this page and download the library: Download amethyst/action 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/ */
amethyst / action example snippets
namespace App\Events;
class DummyEvent
{
public $message;
public function __construct(string $message)
{
$this->message = $message;
}
public function getData()
{
return [
'message' => $this->message
];
}
}
namespace App\Actions;
use Illuminate\Support\Facades\Log;
use Amethyst\Actions\Action;
use Railken\Bag;
class LogAction extends Action
{
public function e);
$next($data);
}
}
namespace App\Actions;
use Illuminate\Support\Facades\Log;
use Amethyst\Actions\Action;
use Illuminate\Support\Facades\Event;
use Railken\Bag;
class EventListenerAction extends Action
{
protected $event;
public function dispatch(Closure $next, Bag $data)
{
Event::listen([$this->data->event], function ($event_name, $events) use ($next, $data) {
$next($data->merge(new Bag($events[0]->getData())));
});
}
}