1. Go to this page and download the library: Download dtyq/async-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/ */
dtyq / async-event example snippets
declare(strict_types=1);
/**
* Copyright (c) The Magic , Distributed under the software license
*/
namespace App\Controller;
use App\Event\DemoEvent;
use Hyperf\Di\Annotation\Inject;
use Dtyq\AsyncEvent\AsyncEventDispatcher;
class IndexController extends AbstractController
{
/**
* @Inject()
*/
protected AsyncEventDispatcher $asyncEventDispatcher;
public function index()
{
$user = $this->request->input('user', 'Hyperf');
$method = $this->request->getMethod();
$this->asyncEventDispatcher->dispatch(new DemoEvent([123,222], 9));
return [
'method' => $method,
'message' => "Hello {$user}.",
];
}
}