When using the cloud sql proxy especially with cloud run for cloudsql mysql instance connections, these are available as unix sockets like this:
/cloudsql/PROJECT_NAME:REGION_NAME:INSTANCE_NAME
The gcloud documentation says with php pdo (without doctrine) the connection shall be made like this:
$dsn = sprintf(
'mysql:dbname=%s;unix_socket=%s/%s',
$dbName,
$socketDir,
$connectionName
);
// Connect to the database.
$conn = new PDO($dsn, $username, $password, $conn_config);
But if you set DATABASE_URL for:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
like this, you will receive:
An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory