Book Image

Instant Zend Framework 2.0

By : A N M Mahabubul Hasan
Book Image

Instant Zend Framework 2.0

By: A N M Mahabubul Hasan

Overview of this book

Zend Framework 2 is a modern object-oriented PHP framework. It has lots of useful components, which are easy to use and user friendly, helping you get your job done faster. This book shows you how to use the framework components to build a practical MVC application. Topics covered in this application include validation, file upload, database CRUD (create, read, update, and delete) operations, and so on.Instant Zend Framework 2.0 has been specifically created to provide you with all the information that you need to get up with Zend Framework 2 applications. You will learn the basic of Zend Framework 2.0, and get started with building your first Zend Framework MVC application. The book promises to deliver all the information you need to get started with Zend Framework 2.0. Instant Zend Framework 2.0 starts with how to download Zend Framework 2.0 and the skeleton application, and then shows how to configure the skeleton application to use the Zend Framework 2.0. Then it takes you through step-by-step instructions of how to create and configure modules, controllers, views, models, helpers and so on. By following the instructions in the book, you will be able to build a small fully functional database-driven MVC application. You will also learn how to use different framework components like the event manager, Zend log, and how to configure them with the module. This will give you an idea of how to configure any component with the module. After finishing this book you will be able to build a small database-driven web application with Zend Framework 2.
Table of Contents (7 chapters)

Installation


ZF2 requires PHP 5.3.3 or higher, so make sure you have the latest version of PHP.

We need a Windows-based PC, and we will be using XAMPP (http://www.apachefriends.org/en/xampp.html) for our development setup. I have installed XAMPP on my D: drive, so my web root path for my setup is d:\xampp\htdocs.

Step 1 – downloading Zend Framework

To create a ZF2 project, we will need two things: the framework itself and a skeleton application. Download both Zend Framework and the skeleton application from http://framework.zend.com/downloads/latest and https://github.com/zendframework/ZendSkeletonApplication, respectively.

Step 2 – unzipping the skeleton application

Now put the skeleton application that you have just downloaded into the web root directory (d:\xampp\htdocs) and unzip it. Name the directory address-book as we are going to create a very small address book application, or you can name it anything you want your project name to be. When you unzip the skeleton application, it looks similar to the following screenshot:

Step 3 – knowing the directories

Inside the module directory, there is a default module called Application. Inside the vendor directory, there is an empty directory called ZF2. This directory is for the Zend Framework library.

Unzip the Zend Framework that you have downloaded, and copy the library folder from the unzipped folder to the vendor\ZF2 directory.

Step 4 – welcome to Zend Framework 2

Now, in your browser, type: http://localhost/address-book/public. It should show a screen as shown in the following screenshot. If you see the same screen, it means you have created the project successfully.

And that’s it

By this point, you should have a working Zend Framework, and you are free to play around and discover more about it.