Zend - The PHP Company


Getting Started with Zend Server Deployment

For this tutorial, we'll be using a Zend Framework application, because of its convenient project structure: Zend Framework applications have an internal document root folder called "public" where the public files are stored, while the source code and configuration files are stored outside of the document root.

Step 1: Download Zend Server

Visit the download page »

Step 2: Create a Zend Framework project (if you don't have one handy)

Two easy ways to create a new Zend Framework project:

1. Use Zend Studio

2. Use the Zend Framework command line interface

Step 3: Create a deployment skeleton

From a command line interface, run the Zend Server's zdpack tool in your workspace (one level above the base project directory), replacing "ProjectName" with the name of your project:

1 
zdpack create ProjectName

The "zdpack create" command creates a skeleton of project files and directories that allows the Zend Server deployment mechanism to understand how to deploy that application. After creating the deployment skeleton, your project should look something like the image on the right (red highlighted areas are files/directories created by the zdpack tool).

The skeleton files created include the "data" and "scripts" directories underneath the application's root directory. The "scripts" directory contains templates for individual PHP scripts designed to run deployment commands at various points in the deployment process.


Optional step: To illustrate using a deployment script to add functionality tied to a step in the deployment process, we may want to have the application send an email each time it's deployed. To do so, add the following code to /scripts/post_activate.php:

1
2
3
4
5
6
7
8
9
10
11
12

require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
$mail->addTo('notifications@mycompany.com');
$mail->setSubject('New deployment');
$currentAppVersion = getenv('ZS_CURRENT_APP_VERSION');
$mail->setBodyText(
"
New application has been deployed.
Version: {$currentAppVersion}
"

);
$mail->send();

Notice the use of the variable $currentAppVersion – data or metadata about the deployment is available for use in these scripts via environment variables like this one.

Step 4: Modify the deployment XML file

The deployment.xml file in the application's main directory contains the meta information required to get an application up and running.

Note the three nodes highlighted in the main XML file structure. The first is the "eula" node, for specifying the location of an end user license agreement for the application. The other two are "appdir" and "docroot". By default, the "data" directory will be listed in appdir (the base directory of the application), but in this example the base of the project is the same as the base of the application, and thus we blank out the value for that node. Similarly, the value of the docroot node for our application is "public" (the path relative to the application base directory).

Also, note the highlighted elements under the "Add Child" menu – the XML validation specifies the permissible values, making it easy to create a deployment file in a simple XML editor.

Step 5: Create the deployment package

Returning to the command line interface, run zdpack pack, again replacing "<path>/ProjectName" with the path to and name of your project:

1 
zdpack pack <path>/ProjectName

This command creates a ZPK file containing the entire application project complete with deployment descriptors.

Step 6: Deploy using Zend Server

From the Zend Server management console, click on the Applications tab, and click on the Deploy Application button in the top right. Follow the steps in the wizard, and Zend Server will do the rest!





 

Resources
DOCUMENTATION

View Beta Online Help more»

FORUMS

Visit Beta Forum more»

Customer Quote

   When it comes to ROI, we consider our investment in Zend technology to be a benefit on several fronts. It is easy to manage the PHP stack, and the strength of the error detection and reporting helps us reduce the time spent troubleshooting while increasing application availability and responsiveness. With session clustering alone, Zend more than paid for itself the moment we flipped the switch.   

Eric Long Sr. Manager, E-Business, Levolor

   Zend Server paid for itself by virtue of the issues we found and fixed in the first week alone a benefit that is magnified exponentially as our e-commerce application grows.    

Josh Butts Director of Web Development, Offers.com

   We used the Code Tracing feature to optimize the DataCache parameters. It would have been very hard to track this down without the ability to trace the code directly in the production environment. We got a huge performance boost.   

Morgan NilssonSystem Developer, Ateles Consulting AB