Php driver on hostinger

Hey guys, new guy here so please bear with me.
I have a plain web page hosted on hostinger.
It supports php 8.0 and has a mongdb extension which I have enabled.
I tried connecting to my atlas server with a simple test.php code. All I get is some sort of unable to load page, http 500 error. I tried different variations of the code. My impression is that this extension is not properly installed, or rather, I have to install it and maybe I have no clue how to. Any tips?
Should I have signed up for a dedicated server and installed the mongodb php driver through a shell? I have the basic hosting plan I think, not sure I get a dedicated server. But it shouldn’t be hard to make a simple php code and connect to my atlas server right? Is a dedicated server for the php page a must? Seems like overkill to me.
Thanks in advance,
Marcelo

Update: I have managed to use the ssh to connect to my host. I have succesfully installed the package with the composer. Now the problem seems to be on the code itself I guess. Although I still get the very same http 500 error.
Here’s the code nevertheless:

<?php $client = new MongoDB\Client( 'mongodb+srv://myusername:mypassw@apsan.sodk5.mongodb.net/myFirstDatabase?retryWrites=true&w=majority'); $db = $client->test; ?>

Did I miss anything? I simply used the command composer require mongodb/mongodb and installed it through ssh.

Hi Marcelo,

Were you able to resolve this issue… I am facing the same…

any solution to this ?

goto it … instead of client we must use MongoDB\Driver\Manager
source: php - Class 'MongoDB\Client' not found, mongodb extension installed - Stack Overflow

2 Likes

I had the same problem. Solution: go to the advanced settings of website, then php configuration. Enable mongodb in PHP extensions and then install mongodb with composer