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.
Step one: create a new user
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:
memory_limit = 128M
Raising the memory limit is 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
- Log into your server via SSH.
- Change directory to your project. This example assumes it's in the /example.com directory.
[server]$ cd ~/example.com
- Close the repository.
[server]$ git clone git://github.com/zendframework/ZendSkeletonApplication.git
- Change directory.
[server]$ cd ZendSkeletonApplication
- The following folders and files have been created in this new directory
- Locally install Composer into this directory.
- Run the following to install ZendFramework 2:
[server]$ php composer.phar self-update [server]$ php composer.phar install
- This creates a new /vendor directory
- Change your site's web directory to /example.com/ZendSkeletonApplication/public/.
- Visit your site and you'll see ZendFramework 2 is running.