Are there ssh and scp tasks available for phing?
Asked Answered
M

7

5

I would like to do remote deployment from my build machine onto a server. The remoting can be done via ssh commands from a script, but I would rather use phing and a deploy.xml file that would do the automation.

What alternatives do I have to do ssh (and also scp) tasks from within a phing build file?

Mut answered 23/10, 2008 at 10:8 Comment(0)
S
-2

If you really need phing, then afaik there's only exec. If you are open for other tools, have a look at capistrano and my answer in "Setting up a PHP web project, the infrastructure.".

Subprincipal answered 23/10, 2008 at 12:52 Comment(4)
Thanks... I used capistrano in the past and I'm happy with it. However, it means that your team now needs to understand 2 languages (PHP and a bit of Ruby). I would rather go for one solution, but we all must be pragmatic...Mut
That's a true concern. However, a good programmer will learn to handle a capistrano makefile in less than a day. Trust me. For example, I don't do any Ruby usually and I've coded tasks with namespaces in less than eight hours. The docs for capistrano are pretty awesome.Subprincipal
You don't answer the question which is to do public key authentication using Phing tasks.Hammock
@amateur barista: Well, for starters, I answered that there is always <exec />. I then provided an alternative which does it right out of the box. And you can run phing tasks through capistrano too.Subprincipal
B
15

SCPTask in Phing:

copies files to and from a remote host using scp. This task requires the PHP SSH2 extension to function...

Blastoff answered 15/12, 2010 at 11:37 Comment(0)
B
9

I came across a SCP and SSH tasks for Phing yesterday. You will also need to follow the instructions for installing SSH2 for PHP. I wasn't able to get the tasks to work straight out of the box, you might. I modified my copy, if you need I can provide.

Boden answered 28/1, 2009 at 21:25 Comment(1)
If you are using WAMP, all you need to do is left-click the WAMP icon, go to PHP -> PHP Extensions, then enable php_ss2.Hammock
M
5

I ran into the same problem about a year ago and back then i could not find a task. I ended up doing a exec task, this way it was all in the xml file.

<exec command="scp -i keys/id_rsa myfile user@$server:myfile" dir="." />
Mcavoy answered 23/10, 2008 at 11:23 Comment(0)
T
2

I know this is old but there seems to be multiple broken links and some misinformation.

ScpTask: http://www.phing.info/docs/guide/stable/apcs60.html

SshTask: http://www.phing.info/docs/guide/stable/apcs60.htm

Tenderize answered 3/2, 2014 at 20:50 Comment(0)
A
1

For SemanticScuttle, we use rsync to deploy release files to the SourceForge server - also via exec. Rsync understands ssh.

Altimeter answered 12/6, 2011 at 18:13 Comment(0)
R
0

For ssh, there's the ssh2 PECL extension and then Phing has the ssh and scp tasks.

  1. On a Mac, install libssh2 via Homebrew. On Linux, use your package manager.
  2. sudo pecl install pecl.php.net/ssh2-0.12

You can now do this:

<?xml version="1.0"?>
<project name="test" default="test">
  <target name="test">
    <ssh username="vagrant" password="vagrant" host="192.168.123.456"
        command="pwd" property="pwd" display="false" />
    <echo>The current working directory is ${pwd}</echo>
  </target>
</project>
Reunion answered 17/11, 2014 at 10:58 Comment(0)
S
-2

If you really need phing, then afaik there's only exec. If you are open for other tools, have a look at capistrano and my answer in "Setting up a PHP web project, the infrastructure.".

Subprincipal answered 23/10, 2008 at 12:52 Comment(4)
Thanks... I used capistrano in the past and I'm happy with it. However, it means that your team now needs to understand 2 languages (PHP and a bit of Ruby). I would rather go for one solution, but we all must be pragmatic...Mut
That's a true concern. However, a good programmer will learn to handle a capistrano makefile in less than a day. Trust me. For example, I don't do any Ruby usually and I've coded tasks with namespaces in less than eight hours. The docs for capistrano are pretty awesome.Subprincipal
You don't answer the question which is to do public key authentication using Phing tasks.Hammock
@amateur barista: Well, for starters, I answered that there is always <exec />. I then provided an alternative which does it right out of the box. And you can run phing tasks through capistrano too.Subprincipal

© 2022 - 2024 — McMap. All rights reserved.