MongoDB PHP driver not working on Ubuntu AWS - php

I'm trying to install the MongoDB PHP driver Using PHP 7.2 on AWS EC2 Ubuntu.
I used sudo pecl install mongodb. it seems to have installed without any errors.
However, when loading phpinfo() I don't see any reference to Mongo. When I try to run:
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
Fatal error: Uncaught Error: Class 'MongoDB\Driver\Manager' not found in /var/www/html/website/test.php:3 Stack trace: #0 {main} thrown in /var/www/html/website/test.php on line 3
I did put in extension=mongodb.so into my php.ini
I'd appreciate assistance as to why this isn't working.

I tried to install driver using
sudo apt-get install php-mongodb
and it works.

Related

How to rectify Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() after installing composer?

I am using ubuntu 21.04 in that i installed composer by using this command sudo apt-get install composer ,after installing i type composer it's showing following error
HP Fatal error: Uncaught Error: Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Helper/Helper.php:50
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(329): Symfony\Component\Console\Helper\Helper::strlen('h')
#1 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(97): Symfony\Component\Console\Descriptor\TextDescriptor->calculateTotalWidthForOptions(Array)
#2 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(197): Symfony\Component\Console\Descriptor\TextDescriptor->describeInputDefinition(Object(Symfony\Component\Console\Input\InputDefinition), Array)
#3 /usr/share/php/Symfony/Component/Console/Descriptor/Descriptor.php(55): Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication(Object(Composer\Console\Application), Array)
#4 /usr/share/php/Symfony/Component/Console/Helper/DescriptorHelper.php(67): Symfony\Component\Console\Descriptor\Descriptor->describ in /usr/share/php/Symfony/Component/Console/Helper/Helper.php on line 50
please help me to fix this issue
You simply enable mbstring extension it will remove the uncaught error
sudo apt-get install php7.2-mbstring
If you're using PHP 7.4:
sudo apt-get install php7.4-mbstring
Check phpinfo.php for ctype module information. In my case, it wasn't loaded and I didn't see the following:
I activated it in php.ini (location depends on your configuration):
;extension=curl
extension=ctype # uncomment or add this
;extension=ffi
and restart php service. You should see ctype module's block and error should go away.

GD library is still missing after I installed it

So I am creating a website for my virtual airline for xplane-11, and I came across this error:
Fatal error: Uncaught Exception: Required GD library is missing in /var/www/html/vam/captcha/simple-php-captcha.php:13 Stack trace: #0 /var/www/html/vam/index.php(15): simple_php_captcha() #1 {main} thrown in /var/www/html/vam/captcha/simple-php-captcha.php on line 13
I have libgd-dev installed on my ubuntu 20.04 and I also have all the extensions uncommented in my php.ini file in the etc/apache2/sites-available folder. I am really frustrated at this point and any help given will be thanked.
From the command line what do you get if you run
php -m | grep -i gd
If it returns
gd
Then the module is included and running in your version of PHP.
Otherwise I would try the following
apt-get install php-gd
Then run the php -m | grep -gd command again after restarting apache

php v8js on ubuntu - error v8js class not found

I am using ubuntu 14.04 with PHP 5.6 and successfully installed v8js-0.1.3 using sudo pecl install v8js-0.1.3.
I followed this installation process
Installing PHPv8js on Ubuntu.
Which is display when I am using php -m.
But when I call new object of v8js like $v8 = V8Js().
I get the following error :- Fatal error: Class 'V8Js' not found
V8Js is a PHP7 extension for Google's V8 Javascript engine V8 Js.

Fatal error: Class 'MongoDB\Driver\Manager' not found in /srv/www/api/releases/...vendor/mongodb/mongodb/src/Client.php

I am trying to configure MongoDB on the AWS server, but when I try to make an API call, I get the following error:
Fatal error: Class 'MongoDB\Driver\Manager' not found in /srv/www/api/releases/20160912135146/vendor/mongodb/mongodb/src/Client.php on line 56
I have done the following:
Install mongodb, following the instructions here -> install mongodb community edition on ubuntu
installed the php mongodb driver using pecl install mongodb
added extension=mongodb.so to php.ini at etc/php5/cli/php.ini
Started the mongodb service
on the server, I can enter the mongo console with $ mongo
What am I missing here, Please?
PS: the API is developed using Phalcon
I finally found a solution to this. Apparently, the apache server uses a special php.ini file, different from etc/php5/cli/php.ini. This file is located in etc/php5/apache2/php.ini. After installing the mongodb driver using pecl install mongodb, your extension should go in etc/php5/apache2/php.ini i.e add extension = mongodb at the end of etc/php5/apache2/php.ini. Good luck

DrupalGap "Install SDK" Error: Fatal error: Class 'ZipArchive' not found in /../../.. /sites/all/modules/drupalgap/drupalgap.module on line 461

I am new to DrupalGap and while configuring DrupalGap I encountered the following error:
Fatal error: Class 'ZipArchive' not found in /../../.. /sites/all/modules/drupalgap/drupalgap.module on line 461
Reproduce Error
Navigate to Configuration/Web Services/DrupalGap
In the "Directory" section, clicked "Install SDK" button.
I have looked around and haven't found a clear solution to this issue. A user on another SO thread recommended installing the "Zip extension". I've tried that but am still getting the error.
Reference Thread
Fatal error: Class 'ZipArchive' not found in
http://www.php.net/manual/en/book.zip.php
Additional Notes
This "Install SDK" step worked fine on my local environment. I followed the same steps on my server
I'm running a D7 install
I'm using DrupalGap 7.x-1.15
Any help or advice would be greatly appreciated!
Thanks.
You need to install and enable PHP Zip extension to use ZipArchive class
For Ubuntu
PHP7 : sudo apt-get install php7.0-zip
PHP5 : sudo apt-get install php5-zip
Once the archive is installed restart your apache server and DONE !
For Ubuntu
sudo /etc/init.d/apache2 restart

Categories