framework: Undefined class constant 'MYSQL_ATTR_SSL_CA' during `laravel new`
- Laravel Version: 5.8
- PHP Version: 7.2
- Database Driver & Version: (Without pdo_mysql)
Description:
When I run laravel new foo
using php without pdo_mysql
extension, the following error message was output.
% laravel new foo
Crafting application...
(snip)
Generating optimized autoload files
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
> @php artisan key:generate --ansi
In database.php line 58:
Undefined class constant 'MYSQL_ATTR_SSL_CA'
Script @php artisan key:generate --ansi handling the post-create-project-cmd event returned with error code 1
Application ready! Build something amazing.
And the value of APP_KEY
in the .env
file remained empty.
Steps To Reproduce:
Run laravel new foo
using php without pdo_mysql
extension.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (13 by maintainers)
No stack trace was displayed.
I greped under the
foo
directory and found that it is onlyconfig/database.php
that usesMYSQL_ATTR_SSL_CA
.Before using
PDO::MYSQL_ATTR_SSL_CA
, I think that it is necessary to check whetherpdo_mysql
extension is loaded.For example:
Possibly https://github.com/laravel/laravel/blob/f4ff4f4176f7d931e301f36b95a46285ac61b8b8/config/database.php#L58
I solved it installing php*-mysql:
sudo apt-get install php7.2-mysql
We’ve commented that section out for now so it’s opt-in instead. You can do the same in your config: https://github.com/laravel/laravel/commit/a0f6bcc773f3895db0ca4a85101b9a3ef2f95782