Skip to content
DanielBerman edited this page Aug 26, 2013 · 2 revisions

A target is a reference to a container that hosts your PHP applications. This container can be a set of targets, and possibly be managed as a cluster. Developers usually start by adding their target environments, such as their localhost server or any other remote server.

Listing Targets

To generate a list of targets, use this command:

zend list targets [-s]

The flag "-s" tells the command line tool to connect to each target and show its status.

The Zend SDK tool scans the user targets directory looking for valid targets, and then generates the list.

Adding a Target

You can add a target by passing the target's information in command line arguments to the Zend SDK tool.

To add your localhost (http://localhost) server you have a simple detection method, for more information click here.

To add a target, issue the command zend add target, with options that specify an id and host name for the new target. To work with this target, one needs to specify the key and secret key as specified in the Zend Server API Key Management document. Alternatively, you can specify an option file that contains all the required information about your target.

Here's the command-line usage for adding a target:

zend add target [-t <target-id>] -k <key> -s <secret-key> -h <host> 

You can use any id you want for the target, but since you are likely to be creating multiple targets, you should choose a name that lets you recognize the general characteristics offered by the target. You can also choose to not specify any id so it is assigned by the Zend SDK tool. The host must be a valid URL of Zend Server (e.g. http://localhost) or phpCloud (e.g. https://your_name.my.phpcloud.com). There is an optional ability to provide a port, e.g. http://localhost:10081. It may be necessary when server uses a custom port.

Here's an example that creates a target with name "my_target":

zend add target -t my_target -k studio -s cc14b445ad6ed9041d936b7f363a8e5a525275d3960dbb373f35e97e2abcdab2 -h http://dev.zend.com

Alternatively you can specify a file name that lists all the properties of your target. This is helpful in order to quickly add keys for several targets.

zend add target [-t <target-id>] -h <host> -p <properties-file>

The properties in the file should contain the following format:

key=<key>
secretkey=<sk>

Here’s an example how you can create the same target while using a properties file:

zend add target –t my_target –h http://dev.zend.com –p my_server.properties

Where my_server.properties file has the following contents:

key=studio
secretkey= cc14b445ad6ed9041d936b7f363a8e5a525275d3960dbb373f35e97e2abcdab2

Adding a Zend Developer Cloud Target

You can also add your Zend Developer Cloud targets by passing the account's information in command line arguments to the Zend SDK tool.

Given the your Zend Developer Cloud credentials (same as zend.com credentials) you can detect and addall http://*.my.phpcloud.com containers.

Here's the command-line usage for adding a target:

zend add target -d [account-name or account-email]:[account-passwword]

Using the Zend Developer Cloud API, all containers created by you will be detected automatically and are visible to the Zend SDK.

Removing a Target

You can use the zend tool to delete a target. Here is the command usage:

zend remove target -t <id>

When you issue the command, the zend tool looks for a target matching the specified id deletes the targets reference from the user directory. This should not in any way affect your remote server.

### Auto-Detecting the localhost Server Zend SDK tool can help you easily detect your localhost server without requiring you to fill in all the arguments such as keys and hostname. During detection time, two operations are executed:
  1. Finding a suitable key. If it doesn't exist, the tools tries to generate one.
  2. Adding the localhost server as a new target.

To execute the first operation, one needs to have admin privileges as it requires write access to the server configuration files.

Under Linux/Mac:

You will need to first run the detect target to generate the key and only then actually apply it with root privileges using sudo (or any su command).

# detect localhost and generate a key for SDK 
$ ./zend detect target 

# apply secret key
$ sudo ./zend detect target -k <key> -s <secret-key>

Under Windows7:

Use the elevate tool that helps to elevate privileges (bundled as part of Zend SDK tool and is located under the same location of the batch file):

elevate zend detect target