Symfony : An exception occurred in driver: could not find driver - php

I'm currently learning Symfony and Doctrine on Wamp, the problem is when i type the command
php bin/console doctrine:database:create
I have the following error :
In AbstractMySQLDriver.php line 110:
An exception occurred in driver: could not find driver
In PDOConnection.php line 31:
could not find driver
In PDOConnection.php line 27:
could not find driver
It's strange because i have my .env file with my DATABASE_URL correct :
DATABASE_URL="mysql://root:#127.0.0.1:3306/csi_film4?serverVersion=5.7"
I also have on WAMP, the pdo_mysql extension ticked on the Wamp, and i've made sure that the extension is in my php.ini file.
But still, i have the error when i type the command to create a database...
I also did a php -m and php -i command on my command prompt but i don't see any pdo_mysql extensions in the php modules so i kknow these modules are missing but I have no idea how can I download them.
If you have any ideas how can I install the missing modules to my php on my Wamp server, I would be glad to have them !
Thanks!

You need to install MysQl, for Ubuntu just use
sudo apt-get install php-mysql

Related

Mac OSX Catalina install pdo_pgsql extension for PHP

I have a laravel application that I've been trying to run, but I get the following error when hitting the database:
Illuminate \ Database \ QueryException (7)
SQLSTATE[08006] [7] FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0
I'm running postgres 12.1 (have also tried with 12.2, no go), php 7.2.28 (have also tried with 7.4.3, no go). The stack trace also mentions a PDOException, so I tried using pecl to install pdo_pgsql, to make sure I have the needed drivers, but I keep getting the following error:
Build complete.
Don't forget to run 'make test'.
running: make INSTALL_ROOT="/private/tmp/pear/temp/pear-build-bowmanLwaFvm/install-PDO-1.0.3" install
Installing shared extensions: /private/tmp/pear/temp/pear-build-bowmanLwaFvm/install-PDO-1.0.3/usr/local/Cellar/php#7.2/7.2.28/pecl/20170718/
cp: modules/*: No such file or directory
make: *** [install-modules] Error 1
ERROR: `make INSTALL_ROOT="/private/tmp/pear/temp/pear-build-bowmanLwaFvm/install-PDO-1.0.3" install' failed
I've been fighting this for hours today, just to get this application to connect to the database and work properly. Searching around to try different things, like downloading the pdo_pgsql package and manually building it gives the same error.
Help?

PHPMyAdmin Fatal Error - Twig_Error_Loader

Am using PHPMyAdmin 4.8.4, MySQL 5.7.24, PHP 7.3.0, and Apache 2.4.37. Whenever I visit http://localhost/phpmyadmin/ I receive the following error:
Fatal error: Uncaught Twig_Error_Loader: There are no registered paths for namespace "". in C:\wamp64\apps\phpmyadmin4.8.4\vendor\twig\twig\lib\Twig\Loader\Filesystem.php on line 209
This error doesn't occur when using PHP 7.2.13. I've examined the Filesystem.php and I do not see what is causing this problem with PHP 7.3.
Is their an easy way to remedy this error and have PHPMyAdmin work with PHP 7.3?
I had this same problem, try:
brew uninstall php71 //if exists another version delete all
enter brew uninstall --force php
brew upgrade
sudo brew services restart dnsmasq
uninstall valet
composer global update
composer global require laravel/valet
valet install
end install phpmyadmin if exists first uninstall:
brew install phpmyadmin
cd /usr/local/share/phpmyadmin
valet link
Your phpmyadmin start : www.phpmyadmin.test ;)
Don't run ? try:
mysql -uroot
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('root');
and enjoy, code, lives :)
probably the problem is this line in your php.ini :
zend_extension = "......php\ext\php_opcache.dll"
If enabled this original extension of php 7.3.0 phpmyadmin goes on throw exception...

Symfony - An exception has been thrown during the rendering of a template

I have been using Codeigniter for sometime now and thought I would try out Symfony. I am very new to Symfony and working from the demo project. When I launch the demo project in my browser I get this error:
An exception has been thrown during the rendering of a template ("An exception occured in driver: could not find driver") in blog/index.html.twig at line 6.
500 Internal Server Error - Twig_Error_Runtime
3 linked Exceptions: DriverException » PDOException » PDOException »
I am not sure where to begin. Can someone please help me in the right direction?
This is your problem: An exception occured in driver: could not find driver
It means that you haven't installed a proper driver for PDO for the RDBMS, which you are using. Or there is specified some invalid value in the config file.
Ubuntu 16.04 doesn't come with php7 and sqlite3. Please run the following command
sudo apt-get install php7.0-sqlite3
Once I ran sudo apt-get install php5-sqlite and then composer install everything started working.

Symfony and PostgreSQL — this error is driving me crazy

I have installed php 5.6.13, nginx, postgresql (using brew, on Mac OS)
I found in log:
PDOException: could not find driver at /project-folder//vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:40
and thought what this is simple mistake in parameters.yml, but everything is OK in parameters and config.
Command doctrine:schema:create and doctrine:fixtures:load working fine with same settings!
So I checked php:
>> php -m
PDO
pdo_dblib
PDO_ODBC
pdo_pgsql
pdo_sqlite
try clear cache: console cache:clear
remove and set up cache, logs folders with http://symfony.com/doc/current/book/installation.html
But I can not login on the site and everytime have save error PDOException: could not find driver
I have no idea — how it can loading fixtures, but can not find PDO driver, when I try to login on the site.
I tried many time remove and install php56, php56-pdo-pgsql, nginx... Any idea...
UPDATE
Problem solved after restart Mac OS.

PDOException “could not find driver” in 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

Categories