Forward PHP-application's MySQL-connections towards localhost to a remote server, edit ~/.ssh/config:

Host my-remote-database-server
    LocalForward /var/run/mysqld/mysqld.sock 127.0.0.1:3306

Do the same, with HAProxy:

global
    log /dev/log local0 notice
    user haproxy
    group haproxy
    stats socket /var/run/haproxy.stat level admin

defaults
    log global
    retries 2
    timeout connect 3000
    timeout server 5000
    timeout client 5000

listen socket
    bind /var/run/mysqld/mysqld.sock mode 666
    option mysql-check user HAPROXY
    balance first
    server mysql-offsite-1 10.0.0.1:3306 check maxconn 64
    server mysql-offsite-2 10.0.0.2:3306 check maxconn 64
    server mysql-offsite-3 10.0.0.3:3306 check maxconn 64

Why not just use the remote hostname or IP in the PHP-applications?

Imagine you have 100 websites, and all of those connect to a specific IP, localhost. Then you need to move out the database server from localhost to somewhere else. This would require changing all the websites configurations...

Another reason, especially with HAProxy, is that you can handle the load-balancing on the webserver instead of inside the PHP-application. Most PHP-applications don't support load-balanced database servers anyway.