Step 3 – Virtual Host

Step 4 – Zend Framework Tool (ZFTool)

ZFTool is a utility module for maintaining modular Zend Framework 2 applications. It runs from the command line and can be installed as ZF2 module or as PHAR (see below). This tool gives you the ability to:

create a ZF2 project, installing a skeleton application;

create a new module inside an existing ZF2 application;

get the list of all the modules installed inside an application;

get the configuration file of a ZF2 application;

install the ZF2 library choosing a specific version.

Requirements:

Zend Framework 2.0.0 or later.

PHP 5.3.3 or later.

Console access to the application being maintained (shell, command prompt)

Installation using Composer

php composer require zendframework/zftool:dev-master

This command will install the ZFTool inside the vendor/zendframework/zftool directory. Now we can use this tool with this command

php vendor/zendframework/zftool/zf.php

OR you can just download the PHAR package and use it. In that case you don’t need to install it with composer.

Suppose we want to see the list of modules in our project, we can do this by this command:

Step 4 – Module

Zend Framework 2 uses a module system to organize application specific code within each module. Inside the skeleton application there is a directory called module. Inside the module directory we see a directory called Application (module), the skeleton application by default creates this module.

Let’s create a module named Album using the ZFTool. To do that we need to execute this command:

php vendor/zendframework/zftool/zf.php create module Alubm

This will create a Album module with all the required configuration inside the module directory.

Create a Controller

Let’s create a Controller named Album using the ZFTool. To do that we need to execute this command: zf.php create controller {controller-name} {module-name}

php vendor/zendframework/zftool/zf.php create controller Alubm Album

Now configure this controller in the module.config.php with this code:

To monitor your application’s performance you can install Zend Developer Tools. Read more about this tool from here.

Step 5 – Doctrine

What is Doctrine?
Doctrine 2 is an object-relational mapper (ORM) for PHP 5.3.3+ that provides transparent persistence for PHP objects. It uses the Data Mapper pattern at the heart, aiming for a complete separation of your domain/business logic from the persistence in a relational database management system.

What are Entities?
Entities are PHP Objects that can be identified over many requests by a unique identifier or primary key. These classes don’t need to extend any abstract base class or interface. An entity class must not be final or contain final methods. Additionally it must not implement clone nor wakeup or do so safely.