MAMP with Laravel Unix Socket MAMP with Laravel Unix Socket php php

MAMP with Laravel Unix Socket


There is even simple solution. add this to ur .env file

DB_HOST=localhost;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock


On config/database.php:

'mysql' => [            'driver' => 'mysql',            'host' => env('DB_HOST'),            'unix_socket' => env('UNIX_SOCKET'),            'port' => env('DB_PORT'),            'database' => env('DB_DATABASE'),            'username' => env('DB_USERNAME'),            'password' => env('DB_PASSWORD'),            'charset' => 'utf8',            'collation' => 'utf8_unicode_ci',            'prefix' => '',            'strict' => false,            'engine' => null,        ],

On .env:

DB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=mytableDB_USERNAME=rootDB_PASSWORD=1234UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock


Check the environment detection part in the bootstrap/start.php. You should add your machine's name to the array that has local key. (If you don't know your machine's name, run hostname in terminal. If it's something stupid, Google how to change it. It's pretty simple.) Then copy and paste your database configurations to app/config/local/database.php. Create the file if it doesn't exists.