Thứ Năm, 24 tháng 4, 2014

ZendSkeletonApplication [Building Your First Zend Framework Application]


Prerequisites


Beforyou gestarted with setting up your first ZF2 Project, make sure thayou have the following software installed and configured in your development environment:

        PHP Command Line Interface
        Git: Git is needed to check out source code from various github.com repositories
        Composer: Composer is the dependency managementool used for managing PHP dependencies
ZendSkeletonApplication provides a sample skeleton application thacan be used by developers as a starting pointgestarted with Zend Framework 2.0. The skeleton application makes use of ZF2 MVC, including a new module system.

ZendSkeletonApplication can be downloaded from GitHub (https://github.com/zendframework/ZendSkeletonApplication).

To set up a neZend Framework project, we will need to download the latesversion of ZendSkeletonApplication and set up a virtual hosto pointo the newly created Zend Framework project. The steps are given asfollows:

1.       Navigatto a folder location wheryou wanto set up the neZend Framework project:
$ cd /var/www/

2.       Clone the ZendSkeletonApplication app from GitHub:
$ git clone git://github.com/zendframework/ ZendSkeletonApplication.git CommunicationApp


3.     Install dependencies using Composer:
$ cd CommunicationApp/
$ php composer.phar self-update
$ php composer.phar install
The following screenshot shows how Composer downloads and installs the necessary dependencies:


4.       Before adding a virtual host entrwe need to set up a hostname entry in our hosts file so that the system points to the local machine whenever the new hostname is used. In Linux this can be done by adding an entrto the /etc/hosts file:
$ sudo vim /etc/hosts
5.     Add the following line to the hosts file:
127.0.0.1    comm-app.local

The final hosts file should look like the following:



6.       Our nexstep would be to add a virtual host entry on our web server; this can be done by creating a new virtual host's configuration file:
$ sudo vim /usr/local/zend/etc/sites.d/vhost_comm-app-80.conf
7.       Add the following configuration to the virtual host file:
<VirtualHost *:80> ServerName comm-app.local
DocumentRoot /var/www/CommunicationApp/public SetEnv APPLICATION_ENV "development"
<Directory /var/www/CommunicationApp/public> 
DirectoryIndex index.php AllowOverride All
Order allow,deny Allow from all
</Directory>
</VirtualHost>
8.       After configuring the virtual host file, the web server needs to be restarted:
$ sudo service zend-server restart



9.       Once the installation is completed, you should be able to open http://comm-app.
local on your web browser. This should takyou to the following test page :


What just happened?
We have successfully created a new ZF2 project by checking out ZendSkeletonApplication
from GitHub and have used Composer to download the necessary dependencies including
Zend Framework 2.0. We have also created a virtual host configuration that points to the
project's public folder and tested the project in a web browser.

Không có nhận xét nào:

Đăng nhận xét