PHP code example of maludb / client

1. Go to this page and download the library: Download maludb/client 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/ */

    

maludb / client example snippets



use MaluDB\Client;

would default pg's PDO to TCP+localhost which
// then t::fromDsn(
    "postgresql:///mydb?host=/var/run/postgresql",
);

$sp = $client->registerSourcePackage(
    sourceType: 'log',
    contentText: 'oncall: 14:22Z api-gateway 5xx burst',
    originJsonb: ['uri' => 'log://oncall/2026-05-13'],
);

$c1 = $client->registerClaim(
    subject: 'api_gateway',
    verb: 'observed',
    objectValue: '5xx_burst',
    statementText: 'Initial 5xx surge at 14:22Z',
    sourcePackageId: $sp,
);

foreach ($client->retrieve('api_gateway', null, null, null, null, null, 10) as $hit) {
    echo "$hit->objectType {$hit->objectId} {$hit->rank}\n";
}
bash
sudo apt install php-cli php-pgsql
bash
# If composer isn't installed, install it system-wide:
curl -sS https://getcomposer.org/installer -o composer-setup.php
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
rm composer-setup.php
composer --version
bash
cd drivers/php
composer install
MALUDB_TEST_DSN="postgresql:///maludb_bench?host=/var/run/postgresql" \
    vendor/bin/phpunit