mdb-sf-demo
A very basic MongoDB Symfony demo to showcase persistance of object as JSON into MongoDB through Symfony PHP framework and MongoDB PHP driver.
Here are the steps I followed on my macOS Catalina (version 10.15.7):
Install package / dependency manager for PHP
brew install composer
Install PHP
brew install php
At the time of writing this the version installed on my macOS is 8.0.8
Install MongoDB PHP driver
sudo pecl install mongodb
Install Symfony
curl -sS https://get.symfony.com/cli/installer | bash
mv /Users/hjournea/.symfony/bin/symfony /usr/local/bin/symfony
Git clone the demo source code
mkdir Repositories/mdb-sf-demo
cd Repositories/mdb-sf-demo
git clone https://github.com/hourdays/mdb-sf-demo.git .
Install project dependecies especially Doctrine, the object document mapper (ODM)
composer require doctrine/mongodb-odm-bundle
composer install
Launch the server locally
symfony server:start
Specify the MongoDB Atlas connection string inside .env
Replace the following with your own connection string specifications provided by MongoDB Atlas GUI as pictured herefater.
###> doctrine/mongodb-odm-bundle ###
MONGODB_URL=mongodb+srv://<username>:<password>@demo.130he.mongodb.net/?retryWrites=true&w=majority
MONGODB_DB=eazy
###< doctrine/mongodb-odm-bundle ###