
The official RavenDB Client for PHP is now out in beta. You can now make use of a rich client to consume RavenDB with all the usual features you would expect.
To start using RavenDB, run:
$ composer require ravendb/ravendb-php-client
And then you can start using RavenDB in your project. Here are some interesting code samples.
Setting up a document store:
use RavenDB\Documents\DocumentStore;
$store = new DocumentStore(["http://live-test.ravendb.net" ], "Northwind")
$store->initialize();
Loading a document:
$session = $store->openSession();
$company = $session->load(Company::class, $companyId);
echo $company->getName() . "\n";
echo "Located at: " . $company->getAddress()->getCountry() . "\n";
Querying:
$session = $store->openSession();
$orders = $session->query(Order::class)
->whereEquals("customer", $customerId)
->toList();
echo "Orders for " . $customerId . "\n";
foreach($orders as $order) {
echo $order->getId() . " - " . $order->getTotal() . "$\n";
}
Pretty much all other capabilities are also available (unit of work, change tracking, automatic failover, and more).
Please give it a whirl, we’ll love to hear about your experience with RavenDB & PHP.
Woah, already finished? 🤯
If you found the article interesting, don’t miss a chance to try our database solution – totally for free!

