Wednesday 16 July 2014

Starting with ZF2 Developer Crash Guide







Introduction
I have come up with this guide to help software developers set up an environment and working zend framework.I am going to be very brief and straight forward on this and will have an assumption of prior programming knowledge on my entire reader of this.

Initial Installation

  1. Install the following components:
Ø  Install composer https://getcomposer.org/download/
Ø  Intall tortoise svn http://tortoisesvn.net/downloads.html

For composer you will be required to locate path to your php.exe which should be version 5.5 and above.

  1. Install ZF2 skeleton application from : http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html

  1. Open your command prompt ,if composer is rightfully installed, > composer –version will give you some output.
To create a skeleton app:
Type this line on your command prompt:

  >composer create-project -sdev --repository-url="http://packages.zendframework.com" zendframework/skeleton-application C:\Framework\ZK

  1. Going to your root directory you will find the downloaded files,check the root :
C:\Apache24\htdocs\Code\Framework\ZK
For a folder structure of the ZF2 application that you are going to start on

  1. Edit some configuration on the server to add the vhost
Start with the httpd.conf  this is located on your computer under the directory :
C:\Apache24\conf
and uncomment this line below :
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

This allows you to define some virtual host in the web server
Open file httpd-vhosts located on your computer under the directory :
C:\Apache24\conf\extra
and add your virtual hosts(remember to put the default for the rest of your sites)
See below:
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:\Apache24\htdocs" 
</VirtualHost>
<VirtualHost *:80>
    ServerName fileserver
    DocumentRoot "C:\Apache24\htdocs" 
</VirtualHost>
<VirtualHost *:80>
    ServerName 192.168.1.200
    DocumentRoot "C:\Apache24\htdocs" 
</VirtualHost>


<VirtualHost *:80>
    ServerName zf2-tradestar
    DocumentRoot "C:\Apache24\htdocs\Code\Framework\ZK\public"
    SetEnv APPLICATION_ENV "development"
    <Directory "C:\Apache24\htdocs\Code\Framework\ZK\public">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

  1. Add your virtual host to your computer under the file : C:\Windows\System32\drivers\etc
So that you can meake a resolution to the virtual hosts that you have added.
The file is named as hosts


  1. When you have done all this access your web page and you should be having this :







  1. Install doctrine in your folder and other libraries

So far so good am hoping so, much has been done here and the rest you will only need to load the additional libraries to you composer.json located under :
C:\Apache24\htdocs\Code\Framework\ZK

Cd to this directory.
  1. Now creating the additional dependencies , doctrine and php-unit,open the composer.json and add the following lines :


Then go to your command prompt and type:
>composer update

Wait for it to download and update the dependencies.
After Finnish you will need to add a few lines so as to make use of the Doctrine ORM,Add the following lines 

alter file config/application.config.php and Add lines

'modules' => array(
        'Application',
        'DoctrineModule',
        'DoctrineORMModule',
    ),

Enjoy coding in ZF2 Framework!!

No comments:

Post a Comment