PDOException “could not find driver” in php - php

I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command
php app/console doctrine:schema:create
I am getting the following error message:-
PDOException “could not find driver”
I also uncomment this line extension=php_pdo_mysql.dll in php.ini file
I tried to look and google my issue but couldn't resolve my problem. when i run php -m command i am getting the following result:-
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
----
----
Is there a way i can remove this issue ?

In Ubuntu, write in the console
sudo apt-get install php5-gd php5-mysql
and it will work

Hope you are running your project in localhost. In your project folder app/config a file named parameters.ini , Make sure that your Mysql database connection cofiguration is correct. If you are using mysql See database_driver=pdo_mysql is its driver.
Below is an example.
database_driver = pdo_mysql
database_host = localhost
database_port =
database_name = databasename
database_user = msqlusername
database_password = mysqlpassword//if not make blank
mailer_transport = smtp
mailer_host = localhost
mailer_user =
mailer_password =
locale = en
secret = ThisTokenIsNotSoSecretChangeIt
Hope it helps you.

You need to have a module called pdo_mysql.
Look for the following in phpinfo() output,
pdo_mysql => PDO Driver for MySQL, client library version => 5.1.44
to install pdo_mysql you need to do this:
pecl install pdo
pecl install pdo_mysql
and then add the following to your php.ini file:
extension=pdo.so
extension=pdo_mysql.so

brew install php70-pdo-pgsql
in case you installed php7 on mac with brew and, change php version according to what you have installed.

if you are using XAMPP then in php.ini file line no 897(depends on version),
;extension=php_pdo_pgsql.dll
uncomment it , then it appears like below
extension=php_pdo_pgsql.dll
in php.ini file line no 897, then restart XAMPP.

There are two PHP versions installed in my server PHP 5.6 and PHP 7
When I run the command php app/console doctrine:schema:update I have the error : [PDOException] could not find driver
I resolve this error by specifying the PHP version:
php5.6 app/console doctrine:schema:update

Looks like your install is missing the .so files it needs to implement the mysql connection. If you're using a package management system to install PHP then make sure you've installed all the necessary submodules (in this case I think you'll need mysql-dev, and the various PHP PDO modules), though such dependencies should have been resolved for you by the package manager.
If you didn't go through a package manager, then you'll have to compile the required .so files from source.

I had the same problem and for me, it was having multiple PHP versions.
So specifying the full address of the PHP solved the problem.

Adding to Jaspreet Chahal's answer.
When installing PDO as a shared module, the php.ini file needs to be updated so that the PDO extension will be loaded automatically when PHP runs. You will also need to enable any database specific drivers there too; make sure that they are listed after the pdo.so line, as PDO must be initialized before the database-specific extensions can be loaded. If you built PDO and the database-specific extensions statically, you can skip this step(Source).
What I mean is, it should look something like this -
extension=pdo.so should be placed before the extensions of the different database drivers.

Maybe you forget to install doctrine/dbal
composer update
composer require doctrine/dbal
if it didn't work go to your php.ini (according to current version)
and remove ";"
;extension=pdo_mysql.so

Related

PHP Warning: PHP Startup: Unable to load dynamic library 'cassandra.so' (tried: /usr/lib/php/20170718/cassandra

I'm setting up square api, integrated it in client side and now working on server side but for that i need to manage dependencies with composer, while installing composer I got above error.
I was installing composer, when i run composer install, composer was installed but I got the PHP warning in addition i.e
PHP Warning: PHP Startup: Unable to load dynamic library
'cassandra.so' (tried: /usr/lib/php/20170718/cassandra.so
(/usr/lib/php/20170718/cassandra.so: cannot open shared object file:
No such file or directory), /usr/lib/php/20170718/cassandra.so.so
(/usr/lib/php/20170718/cassandra.so.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0
I googled and tried all the solutions that have already been done, but none worked to mine. I have tried:
To find out cassandra at php.ini in /etc/php/7.2/cli but i did't find it.
To install Cassandra by using command sudo apt-get install php-cassandra in /usr/lib/php/20170718, but it still shows the same error.
Update and upgrade the Ubuntu, to make sure that there are no internal errors, if there was any?
I expect to install cassandra and load it dynamically.
The DataStax PHP driver extension is a wrapper around the C/C++ driver and requires installation of all of its dependencies:
C/C++ driver
libuv 1.x
OpenSSL v1.0.x or v1.1.x (depends on how your PHP is built)
The GNU Multiple Precision Arithmetic Library
Since you are using the PHP driver with PHP v7.2 you will need to build the extension as their are no pre-built binaries for this version of PHP:
git clone https://github.com/datastax/php-driver.git
cd php-driver/ext
phpize
cd ..
mkdir build
cd build
../ext/configure
make
sudo make install
Note: The development packages of all of dependencies will be required in order to properly build the extension.
Once the driver is installed you will need to edit your php.ini file to enable the extension which can be located by executing php -r "echo php_ini_loaded_file();":
; DataStax PHP Driver for Apache Cassandra
extension=cassandra.so
To ensure the the driver is being properly loaded via CLI you can execute the following:
php -m | grep cassandra
or
php -i | grep -A 10 "^cassandra$"
php -m will print out all the extension/modules that PHP was able to load whereas php -i will display more verbose information about your PHP installation configuration.

PHP is Missing mysql pdo Driver

I'm trying to run a Symfony 3 app with php 7 installed from source and I'm getting a Missing PDO driver exception. According to http://pecl.php.net/package/PDO_MYSQL the PDO_MYSQL extension is now part of PHP core.
Q1.a) If I have the PDO_MYSQL extension (which I must, since its core) does that mean that I also have the mysql pdo driver?
Q2.b) Is there further runtime configuration I have to do to make sure that the driver gets used?
I've tried adding
extension=php_pdo.so
extension=php_pdo_mysql.so
to my loaded php.ini file.
Q2.a) Are these the correct extension names? How could I find out?
Q2.b)Do I even have to provide extension references for core php elements?
Finally:
Q3. How can I check whether my PHP install included the mysql pdo driver and how do I make sure that it is being loaded at runtime?
Thanks for your input.
Edit 1: I'm running on Linux Mint.
Edit 2: Here are a couple more details on what I'm seeing on my end:
"On starting up the built in php server I get the following message:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20151012/php_pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0"
This message suggests to me that either the extension references are incorrect or the extension does not exist. I used "dpkg -L php-mysql" and found that the package was installed in "/usr/share/doc/php-mysql" however, when I check in the php-mysql directory, all I see is a changelog and a copyright file (with hiddens shown). Is this the true install location of the package and, if so, should there be more in this directory?
.so implies you are on Linux - did you install PHP as a package. You probably need to install the pdo/mysql package - PHP libraries may be "core", but not necessarily in the main package (confusing, but it just means it's not PEAR delivered, really).
sudo apt-get install php5-mysql
Or, if you're running PHP7:
sudo apt-get install php-mysql
This should restart the apache automatically, but to be sure you could do:
sudo service apache2 restart
The package installer for php-mysql should have put the .so libraries in /usr/lib/php/yyyymmdd/ - if you had installed PHP as a package, it would be looking here.
However, since you installed from source, it seems that PHP is looking elsewhere for the libraries. You can create symlinks from /usr/local/lib/php/extensions/no-debug-non-zts-20151012/ to the package installed libraries.

how to setting directory path postgresql for install driver php cpanel

I want asking about installing driver php postgresql-9.1
I got error message :
Fatal error: Call to undefined function pg_connect() in /home/adminku/public_html/index.php on line 2
When I googling and trying to installing the driver with using easyapache, the problem installing driver show that the directory is no found,
I change the directory data postgresql to another path, because issue partition from my webmaster, but he can't setting about postgresql
and I found article http://docs.cpanel.net/twiki/bin/view/EasyApache/Php/ModulePgsql
it show i can make costum directory :
Notes
EasyApache searches the following locations for the psql binary:
/usr/bin/
/usr/local/bin/
It then runs psql --version to determine the PostgreSQL version on your system.
EasyApache searches the following locations for the pg_config binary:
/usr/local/bin
/usr/bin
If the binary is not found, this module will be skipped.
If you enable this option, --with-pgsql=directory will be added to PHP's configuration options.
have anyone try use this module with costum directory?
in my php.ini the extension using dll not so like usual centOS i knowed. my bos said, it's default from cpanel, but when i try to search php_pgsql.dll with locate, i can't found it, is it because that dll not found? or because my directory engine change?
You need to compile apache with postgreSQL support with easyapache, it will solve your issue.

How do I enable SQLite3 on FreeBSD?

I have a FreeBSD machine already running PHP 5. I'm trying to get Symfony to work but it requires either pdo_sqlite or sqlite3.
If I type on the command line "sqlite3 --version" it outputs 3.7.5
If I edit my php.ini and uncomment any of the sqlite dll's PHP gives me an error about unknown dll's. I went to sqlite's site and downloaded the sqlite3.dll and tried loading the sqlite3.dll extension but it failed with "Unable to load dynamic library".
At this point I'm really not sure what to do.
I suppose, you need to install databases/php5-pdo_sqlite port and configure your PHP accordingly.

PEAR/Pyrus installation

I am installing Pyrus on my CentOS server by using the following command:
$ php pyrus.phar install PEAR2_Pyrus
I am getting an error:
The sqlite3 extension is required.
You must compile PHP with sqlite3 enabled, or install the necessary extension for your distribution.
Since the PHP 5.3 was installed by Plesk control panel itself, I am not sure how to install Pyrus now. Please help!
What is sqlite3 extension?
How to install it?
I had the same problem. sqlite3 might be already installed on your system.
You can enable it by adding this line to the end of your php.ini file:
extension=php_sqlite3.dll
The file php_sqlite3.dll should be in the /ext directory if it is installed.
SQLite is an embedded database, as described on http://de3.php.net/manual/en/intro.sqlite.php
No idea. Ask the plesk support or search the web: http://www.eukhost.com/forums/f16/i-want-install-php-5-my-plesk-server-how-can-i-do-correctly-996/

Categories