php-azure-documentdb
PHP wrapper for CosmosDB (ex DocumentDB) operations (beta version), (*1)
Update January 2018 v1.1
- Use of the x-ms-version 2017-02-22
- PHP 7.0 mini recommended
- Enhanced unit tests
- Adding some errors throws
Usage
Install
composer require crassaert/php-azure-documentdb
, (*2)
Instantiate
$db = new AzureDocumentDB(AZURE_HOST, AZURE_KEY, false);
, (*3)
Databases operation
List
$db->get('database')->_list();
, (*4)
Creation
$db->get('database')->create('my_database');
, (*5)
Selection
$db->get('database')->select('my_database');
, (*6)
Remove
$db->get('database')->delete('my_database');
, (*7)
Collections
Before requesting, you have to select a database (see previous paragraph)., (*8)
List
$db->get('collection')->_list();
, (*9)
Creation
$db->get('collection')->create('my_collection');
, (*10)
Selection
$db->get('collection')->select('my_collection');
, (*11)
Remove
$db->get('collection')->delete('my_collection');
, (*12)
Document
Before requesting, you have to select a database and a collection (see previous paragraph)., (*13)
Creation
$db->get('document')->create($json);
, (*14)
Requesting
Fell free to write your SQL query here., (*15)
$db->get('document')->query('SELECT * FROM my_table');
, (*16)
Remove
You have to select your document before removing it to obtain the internal ID., (*17)
$rid = $document->_rid;
$db->get('document')->delete($rid);
TODO
Implement permissions, triggers, users, sprocs and UDF., (*18)
You can find all features on Microsoft Azure Website, (*19)