I spent a bit of time to find out the proper way of installing Zend framework 2 on my Local XAMPP (Windows system). Here I described the proper way what I found to install Zend framework 2 without any difficulty for you.
XAMPP is the most popular PHP development environment. XAMPP is a completely free, easy to install Apache distribution containing MySQL, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
Zend Framework 2 is an open source framework for developing web applications and services using PHP 5.3+. Zend Framework 2 uses 100% object-oriented code and utilities most of the new features of PHP, namely namespaces, late static binding, lambda functions and closures.
Highlights in Zend Framework 2:
- An entirely re-written event-driven MVC layer
- Components practice dependency injection, supported by our Service Locator and DiC components
- A powerful module management system
- An EventManager, for writing event-driven systems, as well as for creating cut points in your software for introducing cross-cutting concerns.
- A new view layer, architected around analyzing the request and generating a suitable response, be it plain old HTML, or Atom feeds or JSON.
Zend framework 2 skeleton application is set up to use Composer to resolve its dependencies. Therefore, you need to install Composer if its not available in your system.
Composer installation procedure:
Download and run Composer setup executable file from: https://getcomposer.org/Composer-Setup.exe -it will install the latest composer version whenever it is executed.
During installation, please be careful to select php.exe (C:\xampp\php\php.exe) file from your current active PHP (i.e from XAMPP directory)
After installation, you can use ‘composer‘ command from any folder location.
Create your work directory under a XMAPP htdocs folder. C:\xampp\htdocs\zend
You need to create a new local domain to execute your project in a web browser. Open the local virtual host file C:\xampp\apache\conf\extra\httpd-vhosts.conf and insert the below lines
<VirtualHost *:80> ServerName zf2.localhost DocumentRoot C:\xampp\htdocs\zend\public SetEnv APPLICATION_ENV “development” <Directory C:\xampp\htdocs\zend\public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Configure local host file to activate above created virtue host domain. Open the host file C:\Windows\System32\drivers\etc\hosts and insert the below line
Open windows command prompt and navigate into your work directory
Now install Zend Framework 2 using the below command
composer create-project -s dev zendframework/skeleton-application C:\xampp\htdocs\zend
It will take a bit of time to finish this installation. Once installation started you will get notification updates as below:
Right click work directory and install composer ‘Composer Install‘ to rebuild with installed files.
Now Zend Framework 2 skeleton application created without Zend library files.
Download latest Zend Framework 2 from the link http://framework.zend.com/downloads/latest
Once downloaded latest package, Extract it. You will get 2 folders with the name ‘Zend’ and ‘ZendXml’.
Now copy those 2 folders into your work directory under the folder ‘library’. (You need to create ‘library’ folder under your work ‘zend’ folder)
that’s it. Now Zend Framework 2 installed successfully in your local XAMPP.
Open your web browser and call the below URL
You will get the below default page.
Now you can start to work on this Zend Framework 2 application.