Laravel 5: Artisan throw PDOException could not find driver - php

I've found other question like this but none seems to solve my problem. In my case it occurs on any artisan command, even if I just type "php artisan" the output is [PDOException] could not find driver.
I'm running Laravel 5 on Ubuntu 14.04 LTS, with a LEMP stack (PHP 5.6 fpm, Mysql, Nginx). In the config/database.php the default driver is set to mysql.
I've checked the output of php --ini, it seems to load all configuration files:
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/05-opcache.ini,
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-gd.ini,
/etc/php5/cli/conf.d/20-json.ini,
/etc/php5/cli/conf.d/20-mcrypt.ini,
/etc/php5/cli/conf.d/20-mysql.ini,
/etc/php5/cli/conf.d/20-mysqli.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini,
/etc/php5/cli/conf.d/20-readline.ini
If i open /etc/php5/cli/conf.d/20-pdo_mysql.ini i see:
; configuration for php MySQL module
; priority=20
extension=pdo_mysql.so
And this the content of /etc/php5/cli/conf.d/10-pdo.ini is:
; configuration for php PDO module
; priority=10
extension=pdo.so
Inside /etc/php5/cli/conf.d i see pdo ini files symlinked like this:
10-pdo.ini -> ../../mods-available/pdo.ini
20-mysql.ini -> ../../mods-available/mysql.ini
20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini
The symlink match the base directory /etc/php5/mods-available that contains all the ini files:
pdo.ini
pdo_mysql.ini
That's all. If someone already experienced this, some help would be really appreciated. Thanks!

So, after many attempts i finally find out how to fix it: just needed to install php5-sybase package. After that Artisan works perfectly!
I guess on homestead it's already installed, unluckily I needed to configure a bare-bone ISO on a VMWare Workstation.

Related

Symfony WARNING: No configuration file (php.ini) used by PHP

I downloaded PHP using brew on Mac
# Update homebrew
brew update
# Add the tap
brew tap shivammathur/php
# Install PHP 8.0
brew install shivammathur/php/php#8.0
But when I run
symfony check:req
I get
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
Why Symfony doesn't access php.ini file?
Even though php.ini file exists, I checked that by:
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/8.0
Loaded Configuration File: /usr/local/etc/php/8.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/8.0/conf.d
Additional .ini files parsed: /usr/local/etc/php/8.0/conf.d/ext-opcache.ini
Please consider that I am an absolute beginner in PHP
Thank You
I had the same problem as you and i solved it by changing the name of this file.
When i installed php, i created a file php.ini. (a copy of php.ini-development that i renamed in php.ini). I modified a few lines and i installed "Composer".
But when i checked symfony requirements, i saw this problem as you.
When i opened it with VSC i noticed the file was called php.ini.ini.
I think it was "Composer" who changed the name when i installed it.
I renamed it to php.ini and I no longer had this problem.

Call to undefined function mysqli_connect() in CLI but for non-root user only [duplicate]

I'm using Ubuntu LTS 14.04 operating system and I'm trying to test my PHP scripts in the PHP CLI, but wherever my code attempts to connect to MySQL, with commands such as...
$mysqli = mysqli_connect($host,$user,$password,$database);
...,I get the following error:
Fatal error: Call to undefined function mysqli_connect()...
I've reviewed /etc/php5/cli/php.ini AND /etc/php5/apache2/php.ini and have found no difference.
I think that I must enable mysqli support for the command line interface (CLI), but I am uncertain.
How can I correct the error without affecting my current Apache php.ini/configuration/installation?
EDIT:
Based on comments, I ran the following command in terminal:
php --ini
Which displays:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Then, I copied /etc/php5/cli/php.ini to /usr/local/lib/php.ini.
Then, I ran php --ini again, which displays:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /usr/local/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Then, I ran the PHP script from PHP CLI again, and the same error displayed.
Call to undefined function mysqli_connect()
Means the mysqli exension is not loaded.
I've reviewed /etc/php5/cli/php.ini AND /etc/php5/apache2/php.ini and have found no difference.
I would be very surprised if they were same. But in both cases, these are likely to be structured to work with extesnions distributed via packages - i.e. the ini file containing the directive to load the mysqli so extension will likely reside elsewhere and be included (or not) from these files.
Configuration File (php.ini) Path: /usr/local/lib
You have a Frankenstein system. You need to clean this up. Either use the distro's packaged apps or install apps from tarball. Don't use tarballs unless you know what you're doing. Don't mix and match unless you really know what you are doing.
Delete the tarball PHP files
reinstall the Ubuntu PHP cli
reinstall the Ubuntu PHP mysqli extension
test.php:
if (!extension_loaded('mysqli')) {
dl('mysqli.so');
}
in cli,run it:
php test.php
os output:
Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysqli' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysqli: cannot open shared object file: No such file or directory in test.php
you can find and copy mysqli.so from any where, for example:
/usr/local/lib/php/extensions/no-debug-non-zts-20131226$ sudo cp /usr/lib/php5/20131226/mysqli.so ./mysqli.so

Laravel - could not find driver when migrating

Hello I'm using latest version of Laravel, PHP 7.1.9 and MySQL 5.7.19. I'm also using WAMP stack.
When I run the command:
php artisan migrate
I get the following error:
I googled a lot and I' m 100% sure my php.ini file does not have the driver line commented out and the driver is properly working, as seen here:
The driver is obviously present:
Also the path to extension dir is absolute:
extension_dir ="c:/wamp64/bin/php/php7.1.9/ext/"
What else can I do? This thing is driving me crazy
There are 2 php.ini files in the WAMPServer implementation.
One for APACHE which is the one accessed from the menu system and one in each wamp\bin\php\phpx.y.z folder
As you are using the PHP CLI you have to check that all the required extensions are also activated in PHP you are using for the CLI wamp\bin\php\phpx.y.z
Do this from the command line
php --ini
It should show you something like this
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\wamp64\bin\php\php7.0.29\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Look at this param Loaded Configuration File: to see which php.ini file you should be checking.
This post may also be useful to you for making a batch file to run from the command prompt to switch easily from one version of PHP CLI to another from the command window How To Run PHP From Windows Command Line in WAMPServer

Laravel - php artisan migrate issue - driver not found - ubuntu

I am using xampp in ubuntu, while i do php artisan migrate, it showed PDO Exception could not find driver
Then to fix that
I showed me to install mbstring, php_curl etc., i have installed mbstring, then while install php_curl i got error can't locate
root#allau-Inspiron-5558:/home/allau# sudo apt-get install php5-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-curl
when i type php --ini it showed the following
root#allau-Inspiron-5558:/home/allau# php --ini
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/10-opcache.ini,
But i am using xampp in ubuntu, i guess it points the php.ini of /etc/php/7.0 but i want to use php of /opt/lampp how can i do that ?
help pls
PHP that you are using via CLI is different from the one that is being used by XAMPP. XAMPP brings its own PHP, and if you want to run that one via CLI instead the one that you probably got with Ubuntu, then you should add it to your PATH:
nano ~/.bashrc
Then add this line at the end of the file:
export PATH=/opt/lampp/bin:$PATH
...and save it (ctrl+o -> enter -> ctrl+x)

How to enable mysqli support for PHP's CLI

I'm using Ubuntu LTS 14.04 operating system and I'm trying to test my PHP scripts in the PHP CLI, but wherever my code attempts to connect to MySQL, with commands such as...
$mysqli = mysqli_connect($host,$user,$password,$database);
...,I get the following error:
Fatal error: Call to undefined function mysqli_connect()...
I've reviewed /etc/php5/cli/php.ini AND /etc/php5/apache2/php.ini and have found no difference.
I think that I must enable mysqli support for the command line interface (CLI), but I am uncertain.
How can I correct the error without affecting my current Apache php.ini/configuration/installation?
EDIT:
Based on comments, I ran the following command in terminal:
php --ini
Which displays:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Then, I copied /etc/php5/cli/php.ini to /usr/local/lib/php.ini.
Then, I ran php --ini again, which displays:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /usr/local/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Then, I ran the PHP script from PHP CLI again, and the same error displayed.
Call to undefined function mysqli_connect()
Means the mysqli exension is not loaded.
I've reviewed /etc/php5/cli/php.ini AND /etc/php5/apache2/php.ini and have found no difference.
I would be very surprised if they were same. But in both cases, these are likely to be structured to work with extesnions distributed via packages - i.e. the ini file containing the directive to load the mysqli so extension will likely reside elsewhere and be included (or not) from these files.
Configuration File (php.ini) Path: /usr/local/lib
You have a Frankenstein system. You need to clean this up. Either use the distro's packaged apps or install apps from tarball. Don't use tarballs unless you know what you're doing. Don't mix and match unless you really know what you are doing.
Delete the tarball PHP files
reinstall the Ubuntu PHP cli
reinstall the Ubuntu PHP mysqli extension
test.php:
if (!extension_loaded('mysqli')) {
dl('mysqli.so');
}
in cli,run it:
php test.php
os output:
Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysqli' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysqli: cannot open shared object file: No such file or directory in test.php
you can find and copy mysqli.so from any where, for example:
/usr/local/lib/php/extensions/no-debug-non-zts-20131226$ sudo cp /usr/lib/php5/20131226/mysqli.so ./mysqli.so

Categories