Symfony2 on Zend's phpcloud.com

by Joan Ging / twitter: @mindfulbreath


I am in no way affiliated with Symfony or Zend

What I Assume



What This Won't Cover



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 phpcloud.com

Step 1 - Prepare Symfony2


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

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


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

    Symfony/web/config.php

  • REPLACE the following lines of code:

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


    with:

    /* DISABLED FOR PHPCLOUD
    if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
        '127.0.0.1',
        '::1',
    ))) {
        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+)';
    }


    with:

    /* DISABLED FOR PHPCLOUD
    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:

    Symfony/app/parameters.ini

    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:

    Symfony/.htaccess

    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 phpcloud.com 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 jging.my.phpcloud.com 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        |-- /.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



Congratulations!



Please Provide Feedback

provide feedbackask questions

Additional Resources



Symfony2 - The Book
phpcloud.com Help(requires phpcloud.com login)
Test Drive Zend Developer Cloud with Zend Studio 9
Zend Studio + GitHubHeart This Page
Heart This Page
Heart This Page