1. Go to this page and download the library: Download quazardous/gramphp-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/ */
quazardous / gramphp-bundle example snippets
use Quazardous\GramPHP\Driver\Mariadb\Query;
use Quazardous\GramPHP\Driver\Mariadb\Transaction;
use Quazardous\GramPHP\NodeJournal;
final class ShipWorker
{
public function __construct(
private readonly NodeJournal $ordersJournal,
private readonly Transaction $transaction, // retries a unit on a deadlock
) {}
public function __invoke(): void
{
$lease = $this->transaction->run(fn() => $this->ordersJournal->claim(
'ship', 50, new Query('SELECT id FROM orders WHERE paid = 1 ORDER BY id'),
));
foreach ($lease as $orderId) {
// … ship it …
}
$this->transaction->run(fn() => $this->ordersJournal->conclude('ship', $lease, $lease->token));
}
}