Docs Menu
Docs Home
/ / /
Laravel MongoDB
/

Download and Install

To create the Quick Start application, you need the following software installed in your development environment:

  • PHP

  • Composer

  • A terminal app and shell. For MacOS users, use Terminal or a similar app. For Windows users, use PowerShell.

Complete the following steps to install and add the Laravel MongoDB dependencies to a Laravel web application.

1

Laravel MongoDB requires the MongoDB PHP Extension to manage MongoDB connections and commands. Follow the Installing the MongoDB PHP Driver with PECL guide to install the MongoDB PHP Extension.

2

Ensure that the version of Laravel you install is compatible with the version of Laravel MongoDB. To learn which versions are compatible, see the Compatibility page.

Run the following command to install Laravel:

composer global require laravel/installer

When the installation completes, the command outputs the following message:

Using version ^<version number> for laravel/installer
3

Run the following command to generate a new Laravel web application called my-app:

laravel new my-app

When the installation completes, the command outputs the following message:

INFO Application ready in [my-app]. You can start your local development using:
➜ cd my-app
➜ php artisan serve
New to Laravel? Check out our bootcamp and documentation. Build something amazing!
4

Navigate to the application directory you created in the previous step:

cd my-app

Run the following command to add the Laravel application encryption key, which is required to encrypt cookies:

php artisan key:generate
5

Run the following command to add the Laravel MongoDB dependency to your application:

composer require mongodb/laravel-mongodb:^4.6

When the installation completes, verify that the composer.json file includes the following line in the require object:

"mongodb/laravel-mongodb": "^4.6"

After completing these steps, you have a new Laravel project with the Laravel MongoDB dependencies installed.

Note

If you run into issues, ask for help in the MongoDB Community Forums or submit feedback by using the Rate this page tab on the right or bottom right side of the page.

Create a MongoDB Deployment

Back

Quick Start

Next

Create a MongoDB Deployment