Symfony PDOException could not find driver - symfony

I have a problem with symfony2.3, today I have this error message : "PDoException could not find driver" while yesterday everything worked perfectly.
When I run this command line : php app/check.php All is ok :
OK PDO should be installed
OK PDO should have some drivers installed (currently available: sqlite)
In my file parameters.yml all is correctly.
I do not understand why it worked yesterday and today I have this error.
Best regards,

First of all, verify your php.ini file: the extensions (php_pdo_pgsql or php_pdo_mysql) and php_pdo must be enabled. Make sure you apply this changes on php.ini file that your symfony project is using, check this on localhost/path_to_your_project/web/config.php. You know if this extensions are enabled executing the function phpinfo().
This command is also helpfull: php -m. It lists on console all the php modules that are loaded.
Tip: check out you Apache error log, there could be something wrong with the load of your extensions. This file is located according to your server configuration.

Related

Symfony doesn't detect intl extension (running on XAMPP)

Symfony Profiler tell me this deprectation message : Please install the "intl" PHP extension for best performance.
I enabled intl extension in my php.ini file and it appears in phpinfo, but the deprectation message still appears in Symfony.
I'm using XAMPP server on Windows 10.
Any idea to fix this problem ?
I don't understand precisely why but this fixed my problem : i updated the Symfony Intl package (from 5.0.4 to 5.0.7) inside my project and the message disappeared.

How can I turn my Symfony 4 application from dev mode into production mode?

On my local host I am able to turn the environment from development mode into production mode by changing in .env:
APP_ENV=dev
into
APP_ENV=prod
and after this I clear the cache in the terminal:
php bin/console cache:clear --env=prod
This works fine on the local machine. But on my server I am not able to clear the cache with this command.
The terminal outputs the error:
Parse error: syntax error, unexpected '?' in www/project/bin/console
So on my page I see only:
Oops! An Error Occurred The server returned a "404 Not Found".
Something is broken. Please let us know what you were doing when this
error occurred. We will fix it as soon as possible. Sorry for any
inconvenience caused.
Check your console selecte php version. It can differ to the version of php-fpm configured in your nginx virtual host. You need at least 7.1
Check
php -v
If you have multiple php versions installed, you can change current console php version with this:
sudo update-alternatives --config php
I will provide your with a list of possible php versions that currently installed on your server.

Launch project symfony in browser [duplicate]

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

Install Fixtures in Sylius - Symfony2

After having successfully installed and updated all vendors in my project folder for Sylius i tried running this code :
app/console sylius:install --fixtures
I get this error :
PHP Fatal error: Class 'ResourceBundle' not found in C:\wamp\www\sylius\vendor\
symfony\symfony\src\Symfony\Component\Locale\Locale.php on line 51
Then i tried all possible solutions given here
Installed intl extension in php (working successfully).Then ran this command
php build-data.php 'your ICU version'
On running the above command i get this:
'which' is not recognized as an internal or external command,
operable program or batch file.
The command "svn" is not installed
I want to know if there is another workaround to this issue.
Please help and thanks in advance.
P.S. - No SVN runs on my system. And i'm using icu*46.dll
Anyone came across this??
This error relates to be PHP intl-extension. Make sure it is enabled and you have the LATEST version.
quick test:
<?php
var_dump(extension_loaded('intl'));
Make sure your PHP folder is correctly registered in your %PATH% environment variable.
Control Panel - System - Advanced - ...
Without that, the ICU dlls are not loaded by PHP as Apache module - no error message is displayed, but the extension is not enabled.
Check aswell from phpinfo() ! not with ...
php -m
... or ( windows = findstr, linux/cygwin = grep )
php -i | findstr intl
check that the extension is enabled in your php.ini ( dont know WAMP's extenion path so adjust it please )
extension=php_intl.dll
As i can see you are on Windows and using WAMP you will have to get a precompiled version of the extension.
The packages on http://windows.php.net/download/ all contain the php_intl.dll in the ext folder.
Make sure that the ICU is compiled with the same version of MSVC that PHP is.
You run into problems if the ICU was compiled with VC10 and PHP was with VC9.
Although php -m and php -i detect the INTL it wouldn't show up in phpinfo().

how to use apc in symfony2

I'v just install and configured a clean copy of Symfony2 framework and included in php.ini the extension
php_apc_319_php54_vc9_win7-2008.dll
restart apache and run the url "http://localhost/Symfony/web/app_dev.php/"
it was all fine until refreshing the page and getting an error :
Fatal error: Call to undefined method
Symfony\Component\ClassLoader\ApcUniversalClassLoader::registerNamespaces()
in E:\phpWorkspace\www\Symfony\app\autoload.php on line 10.
I'v allready read this chapter about performance
but maybe I didn't use it well
I'm a novice with symfony so I will be very happy to get astep by step tutorial
You need to install Apc in php
Install apc link1
Install apc link2
I would guess from the file you are using (php_apc_319_php54_vc9_win7-2008.dll) that this dll purports to provide APC 3.1.9 for use with PHP 5.4. Support for PHP 5.4 wasn't added to APC until 3.1.10, and even now is only officially in beta.
At time of writing, the latest version is 3.1.13. I would install that before investigating anything else.

Resources