1. Go to this page and download the library: Download danilovl/async-bundle 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/ */
declare(strict_types=1);
namespace App\Controller;
use Danilovl\AsyncBundle\Attribute\PermissionMiddleware;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{
Request,
Response
};
class HomeController extends AbstractController
{
public function __construct(private AsyncService $asyncService)
{
}
public function index(Request $request): Response
{
$this->asyncService->add(function () {
// add callback with priority 0 and without name
});
$this->asyncService->add(function () {
// add callback with priority 10
// higher means sooner
}, 10);
$this->asyncService->add(function () {
// add callback with priority -10
// less means later
}, -10);
$this->asyncService->add(function () {
// add callback with priority and name
}, 90, 'sendEmail');
$this->asyncService->add(function () {
// add second callback with priority and same name
}, 100, 'sendEmail');
// remove all callbacks with name 'sendEmail'
$this->asyncService->remove(['sendEMail']);
// remove all callbacks with name 'sendEmail' and priority
$this->asyncService->remove(['sendEMail'], 100);
// remove all callbacks
$this->asyncService->reset();
return $this->render('home/index.html.twig');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.