2.8.16. Work with MongoDB

Attention!

You can only work with external databases; MongoDB databases are not supported on our hosting.

To connect to external MongoDB databases, you need to enable the mongodb module and install the library to work with it.

The mongodb module is available on the hosting in two versions:
  • mongodb (v 1.x) — PHP 5.4-8.4 (for PHP 5.4 and 5.5, only outdated versions of the extension are supported — 1.2.11 and 1.6.0, respectively).
  • mongodb2 (v 2.x) — PHP 8.1-8.4.
  1. Open the "PHP settings" section.
  2. In the "PHP Modules" section, enable the "mongodb" module of the required version and save the changes.
  3. Wait 10-15 minutes for the changes to take effect.
  1. Connect to the hosting via SSH.
  2. Go to the desired directory (instead of example.com/www/, specify the path to the desired directory):
    cd ~/example.com/www/
  3. Install the extension using ini file of the site (instead of www.example.com, specify the site for which the mongodb module is enabled):
    php -c ~/.system/php/www.example.com.ini -f /usr/local/bin/composer require mongodb/mongodb
Teneur