Getting Started with Zend Framework2 (ZF2)

Step 01 – Install the Zend Skeleton Application

Type in your Terminal


cd my/project/dir
git clone git://github.com/zendframework/ZendSkeletonApplication.git
cd ZendSkeletonApplication
php composer.phar install

Step 02 – Test the Zend Skeleton Application

cd public
php -S localhost:8888

Test it in your browser just typing the url “localhost:8888” .

Step 03 – Update the ‘composer.phar’ again

php composer.phar self-update
php composer.phar install

Step 04 – Create a Virtual Host
Create the following text file as “zf2.txt” in the “/etc/apache2/sites-available” directory.

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf2-tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Make sure that you update the /etc/hosts file so that zf2-tutorial.localhost is mapped to 127.0.0.1

127.0.0.1               zf2-tutorial.localhost localhost

Then type the following in terminal

sudo a2ensite zf2

Step 05 – Finish

The website can then be accessed using http://zf2-tutorial.localhost

Zend Skeleton-Application.hello-world

Leave a Comment