Unable to generate pdf on server side in NGNIX - php

I am using Dompdf (v-0.8.2) to generate pdf on the server-side. My server is NGINX and I am using CodeIgniter 2.41 (PHP framework) for PDF generation.
PDF is being generated in the localhost without any errors whatsoever.
But when I try to generate the same pdf on the server side it gives this error,
[error] 31558#31558: *4 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error:
Call to undefined function Dompdf\mb_internal_encoding() in
/application/libraries/dompdf/src/Dompdf.php:274
Stack trace:
#0 /application/libraries/Pdf.php(17): Dompdf\Dompdf->__construct()
#1 /system/core/Loader.php(1100): Pdf->__construct()
#2 /system/core/Loader.php(976): CI_Loader->_ci_init_class('pdf', '',
NULL, NULL)
#3 /system/core/Loader.php(217): CI_Loader->_ci_load_class('Pdf', NULL,
NULL)
#4 /application/third_party/HMVC/Loader.php(138): CI_Loader-
>library('pdf', NULL, NULL)
I tried upgrading my dompdf version to 0.8.5. but still the error is not resolving. Does anyone have an idea of how to resolve the error.
Thank you in advance, cheers. :)

mbstring is a "non-default" extension, that is not enabled by default ;
try to install or enabled mbstring extension
sudo apt-get install php(version)-mbstring
ex.: sudo apt-get install php7.3-mbstring
for enabling extension use sudo phpenmod mbstring

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

MongoDB PHP driver not working on Ubuntu AWS

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.

Class 'Stomp' not found

I am using PHP 7.0 with Apache2 in Ubuntu trusty.
I have installed the STOMP library doing
wget http://pecl.php.net/get/stomp-2.0.0.tgz
pear install stomp-2.0.0.tgz
And adding extension=stomp.so to my php.ini.
With phpinfo() I can see the Stomp installed correctly:
But I have this script:
<?php
$foo = new Stomp('tcp://localhost:61613');
And When I run this error is shown:
PHP Fatal error: Uncaught Error: Class 'Stomp' not found in
/vagrant/www/web/activemq-server.php:3 Stack trace:
0 {main} thrown in /vagrant/www/web/activemq-server.php on line 3
UPDATE:
This problem happens only when the script is run from console. If the script is run from browser then it works correctly.
Did you add the extension to php.ini for the CLI too ?
You can type " php -i | grep -i stomp " in the console to know if the extension is enabled
Check the namespace.
$foo = new \Stomp('tcp://localhost:61613');

PHP Issue with PHAR and ZLIB

I'm trying to install phpbrew on my system.
Ubuntu Server Raring Ringtail 13.04 x64
I downloaded the file from GitHub
It has all permissions set, but everytime i try to decompress and install the phar file it throws me this error:
kkoci#ubuntuweb:~/phpbrew$ php -c /etc/php5/cli/php.ini phpbrew
PHP Fatal error: Uncaught exception 'PharException' with message 'zlib extension is required for gz compressed .phar file "/home/kkoci/phpbrew/phpbrew"' in /home/kkoci/phpbrew/phpbrew:3
Stack trace:
#0 /home/kkoci/phpbrew/phpbrew(3): Phar::mapPhar('phpbrew.phar')
#1 {main}
thrown in /home/kkoci/phpbrew/phpbrew on line 3
zlib extension is already enabled, on web version (apache) of php and on cli as well.
These are the interesting lines of the phpbrew phar
#!/usr/bin/env php
<?php
Phar::mapPhar('phpbrew.phar');require 'phar://phpbrew.phar/Universal/ClassLoader/SplClassLoader.php';
$classLoader = new \Universal\ClassLoader\SplClassLoader;
$classLoader->addFallback( 'phar://phpbrew.phar' );
$classLoader->register();require 'phar://phpbrew.phar/scripts/phpbrew- emb.php';__HALT_COMPILER(); ?>
Please, i can't figure out how to bypass this, as i wrote before, everything is enabled, zlib and phar, i don't know, maybe i'm missing some phar configuration?
Same problem, fixed it doing a configure --with-zlib --with-zlib-dir=/ext/zlib
and then a make install

Categories