I also faced this problem when trying to use google cloud platform SQL for mysql that requires to use a local unix socket.
Every part of the URL is not mandary, it's in the form :
<type>://[user[:password]@][host][:port][/db][?param_1=value_1¶m_2=value_2...]
So for a mysql unix socket if you need to specify user and password, you can do :
mysql://user:password@127.0.0.1/db_name/?unix_socket=/path/to/socket
The 127.0.0.1 part will be ignored.
You can test that this is working through the parse_url
function (that is used by doctrine internally):
php > var_dump(parse_url("mysql://user:password@127.0.0.1/db_name/?unix_socket=/path/to/socket"));
php shell code:1:
array(6) {
'scheme' =>
string(5) "mysql"
'host' =>
string(9) "127.0.0.1"
'user' =>
string(4) "user"
'pass' =>
string(8) "password"
'path' =>
string(9) "/db_name/"
'query' =>
string(27) "unix_socket=/path/to/socket"
}