Wednesday, November 30, 2011

Github to Zend Developer Cloud - the fast way!

In previous posts I discussed several methods of building Web applications using Zend Developer Cloud and github, mainly with tools like Eclipse and Zend Studio. This time, I will show off with a new feature in Zend SDK v0.0.22 (and up) presented by Wojtek Galanciak.

With this feature only one command line is required to deploy applications from github to Zend Developer Cloud. Here is a simple example:

zend deploy application -r git:// -t 0

"Symfony2Cloud" repository is hosted in my github account. Target id 0 is my Zend Developer Cloud container. This command makes sure that the applications is deployed into my Zend Developer Cloud container. As simple as that...

Read more about this command and similar use cases with the new Zend SDK. Release notes are available here.

In my next posts I am going to explain about the new repository management tools, so stay tuned.

Sunday, November 27, 2011

chmod() your phpCloud Web Apps

A common feedback from developers using Web Apps on Zend Developer Cloud is the ability to chmod() directories for deployed applications. For example in Joan Ging's post you can notice that one needs to use external tools (like WinSCP or Zend Studio) to chmod the logs and cache directories that are used by Symfony2, otherwise these directories are write-protected and the application fails to launch.

There are two methods to chmod application directories after the deployment stage and before launching.
So let's review the two alternatives, both of them result in the same state:
  1. Using Deployment Scripts (during deployment phases).
  2. Using Zend Studio (after the application is deployed)

Using Deployment Scripts

One of the new features in phpCloud is the ability to deliver hook scripts alongside the application. There are several types of scripts for each phase in the deployment process (i.e, Staging, Activation).
In the following example, chmod is executed on both logs and cache directories immediately after being executed on their parents.
First we define the "scripts" directory to contain all deployment triggers. This is done as part of the deployment descriptor file (named deployment.xml):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<package xmlns="" version="1.0">

Then we create a post_stage.php file under this directory with this content:
/* @var string holds the application (absolute) path */
$appLocation = getenv('ZS_APPLICATION_BASE_DIR');
/* chmod cache and logs */
chmod ( $appLocation, 0775 );
chmod ( $appLocation . '/app/',0775 );
chmod $appLocation . '/app/cache/', 0775 );
chmod ( $appLocation . '/app/logs/', 0775 );

The complete source code for this application is available in the Synfony2Cloud project on Github.

Using Zend Studio 9.0

Once you deploy your application in Zend Studio, a connection to your container is created under the hood. You can view this connection and modify the directories permissions in the Remote System view.

1. Start by showing (or "unhiding") hidden files. This allows you to browse the ".app" directory which holds all deployed applications.
Go to Preferences > Remote Systems > Files and make sure "Show hidden files" is marked.

2. Browse to the application you want to chmod() by expanding the file tree in the Remote Systems view

3. Right click on the directory and select Properties. 
4. Select the Permissions node, alter the permissions you want to allow and click Apply.

Although Alternative #2 is more flexible, I highly recommend Alternative #1 which streamlines the deployment phase and lets you adjust the code and create an automate deployment process.

Wednesday, November 02, 2011

What is coming up from Zend?

If you have already heard about and Zend Studio 9 or just trying to grasp what new developer workflows Zend is now offering, you may find the new tutorials that the Zend documentation team have put together quite useful. These tutorials take you through end to end real world scenarios and outline what can be achieved with the new tools and platform. These tutorials include:

Building Applications on the Zend Developer Cloud (link)
  • To create GitHub and Zend Developer Cloud accounts. These will be used to maintain a project in GitHub and to deploy on Zend's cloud platform. Github is just an example, you could use other version control system such as Git, Subversion, CVS, Mercurial. 
  • To create a new container in the Zend Developer Cloud. The container holds your application in the cloud.
  • To create a new project from GitHub. You will be using an existing GitHub project to create a new project in Zend Studio.
  • To launch the application on the Zend Developer Cloud and debug it using Zend Studio.
A Guided Tour of Zend Application Deployment Support (link)
  • To create a new project from GitHub in Zend Studio: You will be provided with an existing GitHub account and project.
  • To work with your project's deployment.xml file: Launching a project in Zend Studio with deployment support creates a deployment.xml file. This file enables you to customize your application before the packaging process.
  • To create a ZPK package: Packaging your application enables you to export it to other members of the working process for testing and evaluation.
Deploying Applications to Zend Server (link)
  • To create an API Key. The API Key allows Zend Studio to access your server.
  • To create a new PHP project from SVN in Zend Studio. You will be provided with an existing SVN account and project.
  • To deploy your project on a remote Zend Server.
  • To launch your application. After creating your application, Zend Studio enables you to run your application from within the IDE and in an internal browser
Running Applications on a Local Zend Server (link)
  • To create a new Zend Framework project under the local server document root. 
  • To debug your application and modify code.
  • To launch your application.
Customizing Zend Studio (link)
  • To customize Zend Studio by adding and removing the plugins you want to work with. The Welcome page includes a list of available plugins, which you can add or remove from your Zend Studio.
  • To register Zend Studio. Once Zend Studio is installed, all its features will be available for a 30 day trial. To enable full features after this period of time, you will need to register the product.