Le Duy Khanh
Le Duy Khanh

Reputation: 1369

CakePHP 3 is NOT able to connect to the database due to a missing PHP extension

I am trying to install cakePHP 3.0.0 with WT-NMP, but i got this message:

CakePHP is NOT able to connect to the database.

Database driver Cake\Database\Driver\Mysql cannot be used due to a missing PHP extension or unmet dependency

my php.ini has this:

extension = php_bz2.dll
extension = php_curl.dll
extension = php_gd2.dll
extension = php_imap.dll
extension = php_mbstring.dll
extension = php_exif.dll
extension = php_mysql.dll
extension = php_mysqli.dll
extension = php_pdo_mysql.dll
extension = php_pdo.dll
extension = php_soap.dll
extension = php_sockets.dll
extension = php_sqlite3.dll
extension = php_openssl.dll
extension = php_fileinfo.dll
extension = php_intl.dll

the app.php has this

    'default' => [
        'className' => 'Cake\Database\Connection',
        'driver' => 'Cake\Database\Driver\Mysql',
        'persistent' => false,
        'host' => 'localhost',
        /**
         * CakePHP will use the default DB port based on the driver selected
         * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
         * the following line and set the port accordingly
         */
        'port' => '3306',
        'username' => 'root',
        'password' => '',
        'database' => 'test',
        'encoding' => 'utf8',
        'timezone' => 'UTC',
        'cacheMetadata' => true,

What am I missing? or this is cakePHP 3.0 bug? OR anything to do with WT-NMP. I have been stuck for whole day.

Upvotes: 11

Views: 31242

Answers (6)

Silverworm
Silverworm

Reputation: 1

For Windows:

extension=pdo_sqlite
extension=sqlite3

Upvotes: 0

Amit Dangwal
Amit Dangwal

Reputation: 431

Try this:

For PHP 7.0

sudo apt-get install php7.0-mysql

For PHP 5:

sudo apt-get install php5-mysql

Upvotes: 9

Ash
Ash

Reputation: 9061

Installing the modules for MySQL database connections solved it for me:

#Install the package
sudo apt-get install php5-mysql
#Restart Apache
sudo service apache2 restart

Source: http://guru4cakephp.blogspot.nl/2015/04/install-cakephp-3-on-ubuntu.html

Package details: https://packages.debian.org/sid/php5-mysql

Upvotes: 13

Johna
Johna

Reputation: 1894

Don't just depend on the php.ini reading. Just check if you have installed php[v]-mysql extension. You can check if php_mysql.dll exist in the php extension directory(most probably <path to your php installation>/ext) in your windows based server. In linux you can use the following command check if it is installed.

yum list installed | grep php

It will list down all the php extensions installed.

Upvotes: 1

icc97
icc97

Reputation: 12783

The error message is because of extension = php_pdo_mysql.dll not being installed and enabled in php.ini. If you don't have php_intl.dll enabled you will get an error before checking the database connection.

Your php.ini indicates that you have got php_pdo_mysql.dll enabled, however it may have been that you needed to restart the CakePHP server bin/cake server.

Upvotes: 5

Le Duy Khanh
Le Duy Khanh

Reputation: 1369

Solved this by luck!:

extension = php_intl.dll
extension = php_pdo_mysql.dll
intl.default_locale = en_utf8
intl.error_level = E_WARNING

Upvotes: 14

Related Questions