77
88namespace Deployer \Server ;
99
10+ use phpseclib \Crypt \RSA ;
11+ use phpseclib \Net \SFTP ;
12+
1013class PhpSecLib extends AbstractServer
1114{
1215 /**
13- * @var \Net_SFTP
16+ * @var \phpseclib\Net\SFTP
1417 */
1518 private $ sftp ;
1619
@@ -25,7 +28,7 @@ class PhpSecLib extends AbstractServer
2528 */
2629 public function connect ()
2730 {
28- $ this ->sftp = new \ phpseclib \ Net \ SFTP ($ this ->config ->getHost (), $ this ->config ->getPort ());
31+ $ this ->sftp = new SFTP ($ this ->config ->getHost (), $ this ->config ->getPort ());
2932
3033 switch ($ this ->config ->getAuthenticationMethod ()) {
3134 case Configuration::AUTH_BY_PASSWORD :
@@ -38,7 +41,7 @@ public function connect()
3841
3942 case Configuration::AUTH_BY_PUBLIC_KEY :
4043
41- $ key = new \ phpseclib \ Crypt \ RSA ();
44+ $ key = new RSA ();
4245 $ key ->setPassword ($ this ->config ->getPassPhrase ());
4346 $ key ->loadKey (file_get_contents ($ this ->config ->getPrivateKey ()));
4447
@@ -50,7 +53,7 @@ public function connect()
5053
5154 case Configuration::AUTH_BY_PEM_FILE :
5255
53- $ key = new \ phpseclib \ Crypt \ RSA ();
56+ $ key = new RSA ();
5457 $ key ->loadKey (file_get_contents ($ this ->config ->getPemFile ()));
5558 if (!$ this ->sftp ->login ($ this ->config ->getUser (), $ key )) {
5659 throw new \RuntimeException ('Could not login with PhpSecLib. ' );
@@ -103,7 +106,7 @@ public function upload($local, $remote)
103106 $ this ->directories [$ dir ] = true ;
104107 }
105108
106- if (!$ this ->sftp ->put ($ remote , $ local , NET_SFTP_LOCAL_FILE )) {
109+ if (!$ this ->sftp ->put ($ remote , $ local , SFTP :: SOURCE_LOCAL_FILE )) {
107110 throw new \RuntimeException (implode ($ this ->sftp ->getSFTPErrors (), "\n" ));
108111 }
109112 }
0 commit comments