J'ai une installation XAMPP avec Php 8.
J'essaye de tester les fonctions async en php via ce package:
https://github point com /spatie/async/ (je ne peux pas mettre le lien)
J'ai installé composer depuis leur site, ensuite j'ai lancé un PowerShell puis
cd C:\xampp\htdocs
composer require spatie/async
Ensuite j'ai juste copié leur example dans un fichier test.phpuse Spatie\Async\Pool;
$pool = Pool::create();
foreach ($things as $thing) {
$pool->add(function () use ($thing) {
// Do a thing
})->then(function ($output) {
// Handle success
})->catch(function (Throwable $exception) {
// Handle exception
});
}
$pool->wait();
Mais j'ai ce message d'erreur sur ma page php:Fatal error: Uncaught Error: Class "Spatie\Async\Pool" not found in C:\xampp\htdocs\test.php:35 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test.php on line 35
Il n'est pas détecté malgré l'installation avec composer require... Comment puis-je installer correctement Spatie/Async?
Merci