---
title: "Batched commands"
description: "Guide to performing batched operations like BatchWrite, BatchRead, and BatchDelete using the Aerospike PHP client."
---

# Batched commands

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

The following example code performs a batched command.

```php
<?php

namespace Aerospike;

$namespace = "test";

$set = "test";

$socket = "/tmp/asld_grpc.sock";

// Create the client connection

$client = Client::connect($socket);

echo "* Connected to the local daemon: $client->hosts \n";

// Define a key with a namespace, set name, and user-defined key

$key = new Key($namespace, $set, 1);

$wp = new WritePolicy();

// Create a new record

$client->put($wp, $key, [new Bin("bini", 1), new Bin("bins", "b"), new Bin("bin1", [1, 2, 3, 4])]);

// Set up the batch operation

$bwp = new BatchWritePolicy();

$exp = Expression::lt(Expression::intBin("bin1"), Expression::intVal(1));

$batchWritePolicy->setFilterExpression($exp);

$ops = [Operation::put(new Bin("put_op", "put_val"))];

$bw = new BatchWrite($bwp, $key, $ops);

$brp = new BatchReadPolicy();

$br = new BatchRead($brp, $key, []);

$bdp = new BatchDeletePolicy();

$bd = new BatchDelete($bdp, $key);

// Execute the batch operation

$bp = new BatchPolicy();

$recs = $client->batch($bp, [$bw, $br, $bd]);

var_dump($recs);
```