Setting up a connection to the Zend Developer Cloud on Linux

1 Comment

Connecting with the Zend DevCloud in Linux is actually quite easy if you know how to use SFTP.  When you first created your DevCloud account you would have been prompted to download your private key.  This is a private key that is generated, but not stored, on the DevCloud.  You can then connect with the simple command

or also with the -i flag if your private key is not in the default location.  Note, your container cannot be in a hibernating or sleep state.  If you get an error saying “permission denied” when you connect via SFTP it means that your container is probably not running.  Simply log in at with your credentials and your containers will automatically start to spin up.

But, as I said in a previous post, I hate having to do command line stuff for each and every file or commit.  I like things to work seamlessly.  So what I did was write a PHP script that connects to the DevCloud (or any SSH-based endpoint for that matter) and then monitors all of the files and directories for changes, such as a creation, modification or deletion event.  It utilizes the inotify functionality in the Linux kernel and, as such, it requires the inotify PECL extension to be installed.  Since it also uses SFTP you will also need the SSH2 extension (which is bundled with Zend Server).

Then you need to add the extension to php.ini.

Next you need to download the INotify/Push Changes script from GitHub.  There are several arguments, all of which are necessary to make the connection.  They all follow the –option=value format.  I could have used something more elegant but I really didn’t care.  🙂  The options are

  • project_dir – The local location of your project files
  • container – The name of the container you are connecting to, such as
  • username – Your username
  • remote_dir – The remote directory where your application is deployed.  It will probably be something like /.apps/http/__default__/0/cli/1.0-zdc/public.
  • pubkey – This is the file that has your public key
  • privkey – This is the file that has your public key

Calling this script would be similar to this

after which you will see some watches being added

If you edit a file in your Linux editor of choice you can then watch all of the changes that are being made and being uploaded.

One of the things I would like to add would be automatic synchronization but getting the files uploaded was the first priority.  One thing that also doesn’t seem to work is replicating rm -rf.  I saw the calls being made but the unlink didn’t work.  Maybe some work for when I have more time on my hands.

One thought on “Setting up a connection to the Zend Developer Cloud on Linux

Leave a Reply

Your email address will not be published. Required fields are marked *