0

I am trying to run a new Laravel app on my sever but I am getting the following error:

QueryException (SQL) could not find driver (SQL: select * from settings limit 1)

Using the debugbar I can see the error is for PDO: LOG.error:

PDOException: could not find driver in /home/mysite.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:

What doesn't make sense is that I actually already have PDO installed, I know this because I ran the first php artisan migrate and it created all the tables in my MYSQL DB fine.

I have ran php -m | grep mysql to verify what mysql related PHP extensions I have:

$ php -m | grep mysql
mysqli
mysqlnd
pdo_mysql

I should note that PHP can use MySQL as I have a Wordpress blog running on the same server fine.

I have already tried clearing the cache and updating composer packages, I have also completely removed doctrine/dbal and reinstalled.

Update: If I remove the package doctrine/dbal and clear the caches, I still receive an error about PDOExceptions:

Illuminate\Database\QueryException could not find driver /home/mysite.com/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php#68

InvalidSyntax
  • 9,131
  • 20
  • 80
  • 127
  • did you installed mysql driver? – Felippe Duarte Jan 01 '18 at 22:57
  • Yeah its installed as it has successfully ran the migrations, its just the site which shows this page when I try to load it. – InvalidSyntax Jan 01 '18 at 22:59
  • its a configuration issue, there isn't just 1 php configuration ... the cli configuration sounds good, but the other configuration is missing a driver – lagbox Jan 01 '18 at 23:01
  • Can you elaborate what configuration is missing? – InvalidSyntax Jan 01 '18 at 23:02
  • stupid question, where did you use the doctrine/dbal? is it _mandatory_? if you used plain laravel, i believe you won't need it. and start blame the doctrine/dbal first instead of laravel if migration works. – Bagus Tesa Jan 02 '18 at 01:47
  • @BagusTesa I think this package is required if you rename columns/table names. – InvalidSyntax Jan 02 '18 at 02:10
  • could you be more specific on *rename columns/table names*? – Bagus Tesa Jan 02 '18 at 03:05
  • @BagusTesa It allows you to rename columns\tables in migrations, without this you cannot complete this task on certain DB systems (i.e. mysql) – InvalidSyntax Jan 02 '18 at 05:54
  • could you post on how you use this database abstraction layer? i noticed it had [several adapters](https://github.com/doctrine/dbal/tree/master/lib/Doctrine/DBAL/Driver) for different drivers.. and noticed there is no mysqlnd.. the repo did not show on how to use the code, so i could not help much.. this issue is not laravel bound, you should tag it with dbal to draw attention of dbal users. – Bagus Tesa Jan 02 '18 at 13:03
  • @BagusTesa Please see updated question, I don't think this is actually related to `dbal`. – InvalidSyntax Jan 02 '18 at 17:23
  • whoops my bad, it seems indeed `dbal` used by [`laravel/framework` under the hood](https://github.com/laravel/framework/blob/5.5/src/Illuminate/Database/Connectors/Connector.php#L7). could you put back the dbal? also, may we know the database configuration, especially the driver? (it might be stored in either `database.php` or `.env`). also, could you specify the laravel version? also, [a discussion may suggest it is possible to be caused by environment issue](https://github.com/doctrine/doctrine2/issues/6427). is the apache stack is installed manually? (i mean, without LAMPP or equivalent). – Bagus Tesa Jan 03 '18 at 01:06
  • can you check and share if the databse config is the same in cli and web as @BagusTesa said? you can do so with `php artisan tinker` (or in any console command) and in any route callback or controller with `dd(config('database'));` – Gonzalo Mar 24 '18 at 14:24

1 Answers1

0

Try this:

composer update

composer require doctrine/dbal

It looks like you have a missing dependency

Notice:

You might need to comment out the following in your php.ini file.

;extension=pdo_mysql.so

stackoverflow.com/a/42561002/2109233 source

Gonzalo
  • 400
  • 1
  • 9
Arbron
  • 151
  • 2
  • 5