Zend Framework 2 Installation via Composer



In this tutorial I will explain the steps for Zend Framework 2 Installation via Composer.

Steps for install Zend Framework 2 Installation via Composer
  1. First set environment variable D:\xampp\php in Advanced system settings.
  2. Download and install composer from https://getcomposer.org/Composer-Setup.exe
    once you installed automatically composer variable will be added into environment variables (C:\ProgramData\ComposerSetup\bin;)
  3. Now download and install git from http://msysgit.github.io/
    Like below screenshot, select 2nd option when you install.

    GIT install
    GIT install

    Once you installed automatically git variable will be added into environment variables
    (C:\Program Files\Git\cmd)

  4. To check git is installed correctly and configured, just press right click and you will see below screen
    git-options
    Now click on Git Bash Here and you will see below screen.
    git-bash-screen
  5. Now to check composer and php are configured correctly by running below commands.
    open Git Bash
    $ composer –version or $ composer –v
    $ php –version or $ php -v
  6. Now create a directory in your htdocs like say “zendapp”
    Then we have to create composer.phar in this directory
    Go to
    d:\>cd xampp/htdocs/zendapp
    d:\xampp\htdocs\zendapp>

    php -r "readfile('https://getcomposer.org/installer');" | php
    

    Then composer.phar file will be created in zendapp folder.

  7. Now download the zend 2.2.7 skeleton from https://github.com/zendframework/ZendSkeletonApplication by changing branch/tags to 2.2.7 and put these files in zendapp folder.
  8. Now run following commands to update composer and install framework.
    php composer.phar self-update
    php composer.phar install
    
  9. Next in D:\xampp\apache\conf\extra\httpd-vhosts.conf add below lines:
    NameVirtualHost *:80
    <VirtualHost *:80>
    	DocumentRoot "D:/xampp/htdocs/zendapp/public"
    	ServerName www.zendapp.inc
    	ServerAlias zendapp.inc
    	<Directory "D:/xampp/htdocs/zendapp/public">
    		DirectoryIndex index.php
    		AllowOverride All
    		Order allow,deny
    		Allow from all
    	</Directory>
    </VirtualHost>
    
  10. Next in C:\Windows\System32\drivers\etc\hosts file add below line:
    127.0.0.1 www.zendapp.inc zendapp.inc
  11. Finally, once you restart your apache and run www.zendapp.inc you will see below screen.

    Zend Framework 2 Installation via Composer
    Zend Framework 2 Installation via Composer