Deploy PHP with MongoDB in the Cloud

NodeChef cloud provides dedicated PHP hosting with MongoDB hosting based on containers. You can deploy your app without any server experience as you can do everything from the dashboard.

You must first provision your application with a MongoDB database from the dashboard. If you are using an external MongoDB database, you are not required to provision a database with your app. To deploy your application follow the instructions below:

Log in and navigate to the Dashboard. Click on deployments and complete the form. You will be required to select the size of your container and the region where your cluster is to be hosted.

Create your application on NodeChef

After your application is created, click on the Task Manager > App actions > PHP developer

PHP developer

Applications using the latest Mongo Driver

For those using the lastest driver and most likely initiating their PHP client as "new MongoDB\Client("mongodb://localhost:27017");", you are using the new driver and must specify the mongodb extension. You must select a PHP 7.x version and select the mongodb extension

You can use composer here as well, if you run composer require mongodb/mongodb on your terminal, make sure you have the require 'vendor/autoload.php'; in your code. See the official PHP MongoDB docs for more details


Deploying your code

After you have setup your project, you can then zip and upload it from the dashboard, push to your git repository to deploy or use our cli.

If you face any issues, do not hesistate to open an issue in our forums, our team will help you right away

Applications using the legacy Mongo driver

It is important you understand, PHP has two drivers which is the legacy mongo driver and the latest driver which is the extension mongodb

If your application receives the error "Class 'MongoClient' not found" (see issue) or in your code you are connecting to MongoDB using new MongoClient(""), that means you are using the old driver and must use PHP version 5.6 on NodeChef for this to work.

Select PHP 5.6 and then select the mongo extension