Lumen error when using artisan migrate

瘦欲@ 提交于 2019-12-05 16:40:25

Is it possible you forgot to enable the dotenv variables? In your bootstrap/app.php file you can enable the environment variables by uncommenting the following line:

Dotenv::load(__DIR__.'/../');

Lumen Documentation about databases

After a lot of fiddling about, I found the answer.

The problem was with MAMP, the pdo socket for mysql was not in the php.ini file and had to be included there.

[Pdo_mysql]
; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/pdo_mysql.cache_size
pdo_mysql.cache_size = 2000

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket=

Including that line fixed all my probelems.

To the new guys out there trying out Lumen, after 3 sad hours, I finally solved this issue. It's not you, it's the MAMP!

All this time, MAMP was not using the default ports 80 and 3306 for web and mysql. So click that button. That's all! And I'm posting this on my blog soon :D

If you're using MAMP on macOS you can just add this code in your .env file:

DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

And you don't need to modify any MAMP's config.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!