gabordemooij / redbean

ORM layer that creates models, config and database on the fly
https://www.redbeanphp.com
2.31k stars 279 forks source link

R::setup with $tunnel #490

Closed y4nnick closed 8 years ago

y4nnick commented 8 years ago

Would be nice if R::setup would take an ssh2_tunnel parameter to connect with a database over an ssh tunnel.

For example:

    $connection = ssh2_connect('123.123.13.1', 22);
    ssh2_auth_password($connection, 'user', 'pass');
    $tunnel = ssh2_tunnel($connection, '127.0.0.1', 3306);
    R::setup("mysql:host=127.0.0.1;dbname=name","root","rootpass",$tunnel);
gabordemooij commented 8 years ago

I think this should be a plugin or something, not something for the core as this is a very exceptional scenario.

y4nnick commented 8 years ago

Is this possible, since PHP PDO doesn't support ssh tunnels? If you could give me a hint how i could implement it, i would write an plugin.

gabordemooij commented 8 years ago

I have never seen it. I fear you'll have to create your own PDO-compatible object (connect using sockets) and pass it to RedBeanPHP (setup accepts PDO objects). Lot of work...