Laravel Artisan migrations not working? Try this…
Just a quick post here with a tip that may help you if, like me, you’re struggling getting Laravel’s
php artisan migrate command to work.
In my case I was receiving no output whatsoever - no error messages, no logs - and my app was able to write to the database so I knew the credentials were correct, which made the problem very hard to diagnose.
On a hunch I decided to try setting the socket manually as other people using MAMP have had success with it, and thankfully that solved the problem, despite my not receiving the same error message.
.env now has an extra line:
config/database.php has an extra element added to the MySQL settings array:
'unix_socket' => env('DB_UNIX_SOCKET', ''),
Those two additions tell Laravel to look in
.env for a defined socket, or to leave the socket empty if one isn’t defined, which triggers the default DSN generation behaviour in the
For me, this doesn’t affect the functionality of my app but does make the migrations work. Running the socket setting through
.env means it can easily be modified on a per-machine basis without having to worry about source control etc.
Hope this helps someone avoid wasting a lot of time like I did!
Posted on Friday, 29th April 2016.
Sorry, feedback is now closed on this post, but please feel free to get in touch if you would like to talk about it!