This code was writting in conjunction with this article.
You'll need the following installed on your computer to follow along with this tutorial:
- A MongoDB Atlas cluster
- A code editor of your choice.
- We suggeest Visual Studio Code. Check the optional MongoDB for VS Code extension.
The article mentions several ways to get a Laravel development environment up and running.
Before the project can run properly, we need to take several actions.
In the Laravel project folder, install the Composer dependencies with the command
composer install
Laravel uses the .env file for environment-specific configurations, like database credentials, application key, and other settings. Create one from the included example file:
cp .env.example .env
Laravel might ask to generate a new application key. You can do it by running this command in the laravel project folder.
php artisan key:generate
We need to add the MongoDB connection string with the username / password to the .env file. add this line, but remember that your connection string might look different.
DB_URI=mongodb+srv://USERNAME:PASSWORD@clustername.subdomain.mongodb.net/?retryWrites=true&w=majority
Head to the site URL and you should see the Laravel Homepage
The xdebug.php-debug VS Code extension is automatically installed if you launch via devcontainer.json.
If you are using our container directly (docker compose up), or via VS Code (devcontainer), we suggest the following Xdebug configs visual studio
The debug config file is located in <repository_dir>/.vscode/launch.json
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
// ${workspaceFolder} == directory where /.vscode/ is
// the syntax is SERVER_PATH : LOCAL_PATH
"/var/www/htdoc": "${workspaceFolder}/src"
}
},
- TODO
- TODO
Use at your own risk; not a supported MongoDB product