Wednesday, September 14, 2011

"git clone" and "application deploy" - Perfect Match

It's amazing, you work on a pretty cool project for a couple of months now and you find out that little has been posted about it.
So here it is... meet Zend SDK. There are many interesting ideas behind this SDK but in this post I am going to focus on how to get started with it.

So... what is Zend SDK?

If you build a Web Application or even a CMS Web site in PHP you probably have asked yourself a couple of times what best practices should I use to develop, publish and discover applications written in PHP. Amazingly, in most modern platforms like Java, Ruby, Flash, Android and iOS it is common to find a dominant set of tools and workflows to streamline development processes. Things like creating application resources, deploying applications, configuring application hosts and even creating a repository of applications that allows others to discover it. However for several reasons PHP developers don't have one way to do such things, just as an example take a look at the famous PHP applications, frameworks and CMSs solutions in the market. This is exactly where the SDK is aiming.
Zend SDK includes a variety of tools that help you create, develop, publish and discover PHP Web applications.
Hence, you can find command line tool, Eclipse plugin, Hudson/Jenkins, Phing, Ant and other tools in our target environments.

Step 1: Clone your application from a Git repository

First thing first, you will need to fetch the application source code and prepare it for the target environment, to do so you can use the "clone project" command line. With this command a project from a git repository is cloned to your local machine and additional deployment descriptor resource is added that will assist you with hosting this application on targets.
zend clone project -r

Alternatively you can create a local empty project based on the MVC of Zend Framework by clicking
zend create project -n helloworld
If you have already fetched your project (with SVN, CVS or other source control version) you can just update the project with the files required to help you with the deployment process:
zend update project -d 
for more information on project management, read this wiki page which goes over the alternatives and provides extra details about the possible arguments of these commands. If you haven't installed the SDK go to this page

Step 2: Add a remote target

This is the easy part, you will need a target that will host your applications. I assume you installed Zend Server 5.5 and it is accessible by your machine. If not, you will need to install it either locally or on a remote machine.

For example adding a remote target with address with a given secret key is possible by
zend add target -h -k sdk.roy -s cc14b445ad6ed9041d936b7f363a8e5a525275d3960dbb373f35e97e2abcdab2 
This command line will add a new target to the list with the specified API key, for more details on API keys see this page. After installing this target you can use the list target and list applications to see the results:

Example output for a listing command is (read more on targets management here):
royganor@ubuntu:~$ zend list targets -s
Available Zend Targets:
id: 0
	Key: Zend 	Status: connected
Step 3: Deploy your application

Now that your application is ready and your target is configured properly, we can go directly to the fun part. deploying you application to the host.
royganor@ubuntu:~$ zend deploy application
Step 4: Test it!
Now you are ready to see if the application deployed successfully by running a stats command or just going to the browser and address the application URL.

royganor@ubuntu:~$ zend list applications
Id:                     67
Application Name:       drupal
User Application Name:  http://default-server/ExampleProject
Base URL:               http:///ExampleProject
Installed Location:     /home/royganor/.apps/http/__default__/0/ExampleProject/1.0.0
Status:                 deployed
	id:               0
	Deployed Version: 1.0.0
	Status:           deployed
Deployed Versions:	1.0.0

Step 5: What's next?
In next posts more interesting aspects of the SDK will be covered like creating repositories and publishing your applications to others.As usual if you want to. Till next time, I will really appreciate your feedback on Zend SDK

No comments: