@muriel.schmidt
To use the MongoDB database on OctoberCMS, you need to follow these steps:
- Install the MongoDB PHP extension:
Make sure you have MongoDB installed on your server.
Install the MongoDB PHP extension using the following command: sudo apt-get install php-mongodb (for Linux) or brew install php-mongodb (for Mac).
- Install the MongoDB plugin:
In your OctoberCMS project, go to the root directory of the project using the terminal.
Run the following command to install the MongoDB plugin: php artisan plugin:install IndikLab.MongoDb.
- Configure the database connection:
Open the config/database.php file in your OctoberCMS project.
Add or modify the MongoDB database configuration as below:
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '27017'),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'database' => env('DB_DATABASE'),
'options' => [
'database' => 'admin' // Set the database here
]
],
- Set the environment variables:
Open the .env file in your OctoberCMS project.
Set the DB_CONNECTION variable to mongodb.
Set the DB_DATABASE variable to the name of your MongoDB database.
Set other MongoDB related variables as per your configuration, such as DB_HOST, DB_PORT, DB_USERNAME, and DB_PASSWORD.
- Migrate or seed your database:
Run the migration or seed commands to set up your MongoDB collections and data.
- Use the MongoDB database:
You can now use the MongoDB database by creating models and interacting with them using the built-in ORM (Eloquent) or directly using MongoDB queries.
That's it! You have successfully configured and can use the MongoDB database on OctoberCMS.