Installing Zend Framework 2

This article provides instructions on how to implement the Zend framework 2 onto a shared hosting environment. Please note that this guide does not teach you about the Zend Framework 2 itself.

Starting with Zend Framework 2, you may now install using the PHP management tool Composer. This guide uses Composer to install version 2.5.

Installing Zend Framework 2

Step one: create a new user

View the Users article for details on how to create a new username. When creating it, make sure it’s created as an SSH (Shell) user as this allows you to log into your server to run commands later.

For security reasons, it is best to create a new user account to host the domain. Avoid hosting multiple domains on the same user account at all costs! If a hack compromises your account, all the domains running under that specific username can and will be affected.

Step two: create a fully hosted domain/subdomain

View the following article which walks you through how to add a fully hosted domain to your panel:

Makes sure to assign the newly created Shell user to the domain when adding it.

Also make sure the domain is running on PHP 5.6 or above.

Step three: create a phprc file

View the following articles for instructions on how to create a phprc file.

If the file already exists, view the following articles for instructions on how to update it:

extension = phar.so
detect_unicode = Off
phar.readonly = Off
phar.require_hash = Off
suhosin.executor.include.whitelist = phar
memory_limit = 128M

The first five lines are used to turn Phar on and set it up for installation. The memory limit is raised just for the installation process, otherwise it could possibly run out of memory and fail.

Step four: change the default PHP CLI your shell uses

If you wish to have your commands default to a specific version of PHP, view the following article:

Just make sure your shell PHP version defaults to the same version you're running the site under in your panel:

Step five: download Zend Framework 2.5

  1. Log into your server via SSH.
  2. Change directory to your project. This example assumes it's in the /example.com directory.
    [server]$ cd ~/example.com
  3. Close the repository.
    [server]$ git clone git://github.com/zendframework/ZendSkeletonApplication.git 
  4. Change directory.
    [server]$ cd ZendSkeletonApplication 
    The following folders and files have been created in this new directory
    • /.git
    • .gitignore
    • LICENSE.txt
    • README.md
    • Vagrantfile
    • composer.json
    • composer.lock
    • /config
    • /data
    • init_autoloader.php
    • /module
    • /public
  5. Locally install Composer into this directory.
  6. Run the following to install ZendFramework 2:
    [server]$ php composer.phar self-update
    [server]$ php composer.phar install
    This creates a new /vendor directory
  7. Change your site's web directory to /example.com/ZendSkeletonApplication/public/.
  8. Visit your site and you'll see ZendFramework 2 is running.

See also

Did this article answer your questions?

Article last updated .