Deploying your work in Zend Studio is quite easy. You have the ability to deploy directly from your IDE, which is, in general, more for local environments, the Zend Developer Cloud or testing. The reason for this is because generally the developer should not have access to production. Therefore, the drag and drop deployment that Zend Studio supports is usually not going to be used, though in smaller development shops it may still be quite useful.
The deployment mechanism in Zend Server uses a ZPK file, which contains the source code, assets and the deployment descriptor. The deployment mechanism on the server side has already been discussed on this blog.
When creating a deployment package the first you need to do is either create a new project with deployment support
or add it by right clicking on your project and selecting “Add Application Deployment Support”
This will allow you to then either drag the project onto a target to deploy it or, as we’re talking about here, allow you to export it as we’re going to show here.
The deployment.xml file is where all of the configuration information resides. Double click on this file and you will get a display similar to this
Most of the fields are self explanatory but a few might require a few words.
- Document Root – This is the document root (duh) which is relative to the base directory of the deployment. Your project, in other words.
- License – This is the relative path to a text file in the project directory structure that contains the EULA for the project. During the deployment workflow in the UI the end user will be presented with this if the file is available and will be required to agree to it before proceeding.
- Persistent Resources – These are items that you don’t want to have overwritten during an upgrade. For example, cache directories.
There are several different types of dependencies you can specify for your application.
These dependencies will be checked prior to deploying the application. If they are not satisfied then the application will not deploy.
There are several triggers that can be hooked into during the deployment process, each of which has a Pre and Post stage
To set up a trigger simply double click on the stage that you would like to edit and a new file will be created for you. In that file will be documentation on information on how to retrieve variables and parameters for your deployment scripts.
Speaking of variables and parameters, what is the difference? There are two differences.
- Variables you cannot change during the deployment process. What the value is in the deployment file is the value that you will get in the deployment script. Parameters need to be specified during the deployment workflow and also have some validation that you can do on the entered values whereas with variables you do not.
- Both are accessible via getenv() during deployment but variables are retrieved with their names “as is” but parameters are upper cased and prepended with “ZS_”. So if you have a parameter named “ugly_Duckling” it would be accessed via getenv(‘ZS_UGLY_DUCKLING’)
There may be files in your application that you want to include (really!?) or exclude. You can specify those in the Package panel.
The last step is to export your project. Right click on the project and select Export and choose “Deployment Package”. This will output the project into a ZPK file that you can then upload to your Zend Server instance or Zend Application Fabric installation where it will be deployed to your website. Lickety Split.
There are other panels there and other information that I have not included. The reason for that is that it is either relatively self explanatory on not necessary from an initial “getting started” point of view. Or because it’s Friday and I’m running out of time.
The deployment functionality in Zend Server was something that I have personally been waiting for for a long time. This addition in Zend Studio now makes the circle complete. Granted, there will always be more that we can do, but this was a feature that has long been needed and I’m quite glad that it’s here.