"Could Not Find Driver" Message When Executing Query
I have a Laravel project. It was fine until I updated my Ubuntu 19.04 to 19.10. While testing my APIs on Postman I get this error:
"message": "could not find driver (SQL: select * from `users` where `username` = genesis limit 1)",
"exception": "Illuminate\\Database\\QueryException",
"file": "/home/arkhalis/Repos/laravel/safetrade/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
"line": 664
and after that I tried to run Composer
on terminal and got this output
PHP 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
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
Also I have tried to run composer update
and got the same result as this question and run sudo apt-get install php-mbstring
but the same result as I run composer
command on terminal.
Answer
Try to install all the required extension by Laravel. Please take a look here.
You can try to run this command if you're using PHP 7.1:
sudo apt install php7.1 php7.1-fpm php7.1-curl php7.1-mysql php7.1-common php7.1-mbstring php7.1-mcrypt php7.1-xml
Or you can run this command if you're using PHP7.2 (no mcrypt, since it's has been removed)
sudo apt install php7.2 php7.2-fpm php7.2-curl php7.2-mysql php7.2-common php7.2-mbstring php7.2-xml
If you're experiencing an error, maybe you don't have any PHP repo added. Try to add this complete PHP repo by Ondřej Surý.
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Update
Since you're using Ubuntu 19.10 (Eoan), I've heard that by default It comes with PHP 7.3. So, maybe you could try:
sudo apt install php php-fpm php-curl php-mysql php-common php-mbstring php-xml
Right now the ondrej/php
still not release any PHP packages for 19.10 (because Ubuntu 19.10 is released recently). It takes time for the author to released the packages.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms