Symfony2 on Zend's

by Joan Ging / twitter: @mindfulbreath

I am in no way affiliated with Symfony or Zend

What I Assume

I assume that you have already created an account, a container, and an empty application within your container on I also assume that you have set up your SSH key pair in your account on

What This Won't Cover

I am not going to cover how to work with Zend Studio or phpcloud or git at this time, though they all work quite nicely together, along with Symfony2. There are several excellent tutorials online for this already, and I will link them in the Additional Resources section at the end of this article.

What You Will Need

  • Symfony Standard Edition (version 2.0.4 at the time of writing) - be sure to download the version that includes vendors
  • File editor - I used Zend Studio 9 Beta, but text editors will work fine, too.
  • SFTP Client - I used FileZilla , but any FTP client capable of the SFTP protocol via SSH key will work.

Installing Symfony2 on

Step 1 - Prepare Symfony2

  • Unpack the Symfony2 archive. You should wind up with:

        |-- /app
        |-- /bin
        |-- /src
        |-- /vendor
        |-- /web
        |-- deps
        |-- deps.lock
        |-- LICENSE

  • In the file editor of your choice, open the file:


  • REPLACE the following lines of code:

    if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    ))) {
        header('HTTP/1.0 403 Forbidden');
        exit('This script is only accessible from localhost.');


    if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    ))) {
        header('HTTP/1.0 403 Forbidden');
        exit('This script is only accessible from localhost.');

    Disabling this section of code will allow you to run the config script on a remote host. Note: for maximum security you should remove the comment tags to enable this section again once you have finished your configuration.

  • REPLACE the following lines of code:

    if (!(!(function_exists('apc_store') && ini_get('apc.enabled')) || version_compare(phpversion('apc'), '3.0.17', '>='))) {
        $majorProblems[] = 'Upgrade your APC extension (3.0.17+)';


    if (!(!(function_exists('apc_store') && ini_get('apc.enabled')) || version_compare(phpversion('apc'), '3.0.17', '>='))) {
        $majorProblems[] = 'Upgrade your APC extension (3.0.17+)';

    Phpcloud has APC installed, and has the correct functions available. For some reason, the phpcloud instance does not seem to have a version number to compare against and thus fails this test. Preliminary testing seems to indicate the phpcloud instance APC version is adequate, so disabling this check will allow us to move forward with configuration.

  • Save and close Symfony/web/config.php

  • Open the parameters.ini file found here:


    Modify the file as shown below, replacing ‹container› with your phpcloud container name, ‹username› with your phpcloud login username, and ‹password› with your phpcloud login password. You should also put something much more random for the secret string.

    When finished, save and close the file.

  • CREATE an .htaccess file here:


    Open the new file, and put this line at the top:

    php_flag short_open_tag off

    By default the phpcloud instance has the short_open_tag php.ini setting turned on, but Symfony2 would like it to be off. Be aware that this will make it impossible for you to use ‹?=$item?› to print the value of $item. You must use ‹?php echo $item; ?›.

Step 2 - Set Up SFTP

FileZilla FTP Client

  • In FileZilla, IMPORT your private SSH key that you created when you created your container on by going to the Edit > Settings... menu on the toolbar.

    Under Connection on the left, select SFTP. Click Add keyfile... button and locate the private SSH key you downloaded from phpcloud. Note: go ahead and convert the key to a new format if you are prompted to do so. Click "OK" when the key shows in the list.

  • Open the Site Manager:

    File > Site Manager

  • Click "New Site" to create a new connection.

    Complete all of the highlighted fields in the screenshot above, replacing with your phpcloud container URL and using your own phpcloud username. A password will not be required because you are using the keypair to authenticate yourself. Click OK to save the settings and connect.

  • Locate your public web directory. When you connect to your site, you should see something similar to this:

    The public site directory should be located here:

      |-- /.apps
        |-- /http
          |-- /__default__
            |-- /0
              |-- /‹ApplicationName›
                |-- /‹version›
                  |-- /public    <-- PUBLIC WEB DIRECTORY
      |-- /.ssh
      |-- /applications
      |-- /www

    Upload the entire Symfony folder to your public web directory. It may take a while.

  • Set write permissions on the cache and logs directories on the server. While still in your public web directory in your phpcloud application, locate the two highlighted folders:

    To change permissions (chmod), right-click on the folder and select File permissions....

    The numeric value should be set to 777 as shown above. Again, you'll need to do this on both the cache and logs directory.

Step 3 - Complete Symfony2 Configuration

  • Check your configuration. Open your browser and go to:

    For example, if I had a container named jging and I had chosen a path name of FooApp for my application, my URL would be:

    If all goes well, you should see:

  • Can you run the demo? Browse to the following URL, replacing ‹container› and ‹application›:

    Again, if all is well you should see the main Symfony welcome page. Click on RUN THE DEMO to test some of the basic out-of-the-box functions of Symfony2.


Hopefully you now have a successful implementation of Symfony2 on Zend's development cloud.

Additional Resources

Symfony2 - The Book Help login)
Test Drive Zend Developer Cloud with Zend Studio 9
Zend Studio + GitHub