1. Go to this page and download the library: Download phuze/php-cosmos 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/ */
phuze / php-cosmos example snippets
use Phuze\PhpCosmos\CosmosDb;
use Phuze\PhpCosmos\QueryBuilder;
# connect, and select a database and collection
$conn = new CosmosDb('https://myaccount.documents.azure.com', 'your-key');
$database = $conn->selectDB('databaseName');
$collection = $database->selectCollection('Users', '/country');
# find the users in Canada who are over 30
$users = QueryBuilder::instance()
->setCollection($collection)
->setPartitionValue('Canada')
->where("c.age > @age")
->params(['@age' => 30])
->findAll()
->toArray();
$conn = new CosmosDb($host, $key);
$conn->setHttpClientOptions(['timeout' => 120]); # in seconds