0
votes

Currently Azure NoSQL solution DocumentDB doesn't have any PHP SDK. There is a REST API alternative which has several PHP wrappers on Github.

NodeJS example in Azure uses mongodb driver from npm. I can successfully crud documents on DocumentDB with that example. So with an mongo driver it's possible to crud to Azure DocumentDB. Example here

However when i try to connect to Azure DocumentDB with PHP7.0 - mongodb extension installed my server returns empty response. Example scenario

UPDATE: Just realised I can actually connect to Azure DocumentDB in a plain php script with mongodb driver. Problem is possible occuring due to framework I am using "cakephp 2" framework.

UPDATE 2 It's not CakePHP2 but Apache(MAMP).When i isolated the problem I've seen that actually crashes are only occuring with apache. I can use the extension with nginx.

1

1 Answers

0
votes

You seem to be using Mongo, this extension is deprecated. Please use MongoDB instead.

You can download MongoDB driver for PHP from this link. If you are using Windows server, then you can extract the archive and put php_mongodb.dll in your PHP extension directory ("ext" by default).

After that, add the following line to your php.ini file:

extension=php_mongodb.dll

After the driver set-up, you can refer to this tutorial to work with Azure DocumentDB by using the PHP Library for MongoDB.