using-zend-framework-2-book icon indicating copy to clipboard operation
using-zend-framework-2-book copied to clipboard

Samples for the Using Zend Framework 2 book

Code Samples for The "Using Zend Framework 2" Book

This project contains a set of code samples for the Using Zend Framework 2 book by Oleg Krivtsov. Zend Framework 2 is a modern PHP web development framework intended for building professionally looking, scalable and secure web-sites, which are easy to test and maintain.

The book's text is illustrated with code examples that you may want to reproduce yourself. It may be difficult for a novice to write code without mistakes. If you are stuck or can not understand why your code does not work, you can download and install the complete sample web application from this page.

Each sample described on this page is a complete web-site you can install and run yourself to see Zend Framework 2 in action. You even can use the samples as a base for your own web sites.

To download all samples as a ZIP arcive, click the Download ZIP button. When download is complete, unpack the archive to some directory.

The structure of the code archive is presented below.

using-zend-framework-2-book
	helloworld
	formdemo
	blog
	...

Below, we provide a short description for each available sample. For more detailed description, you will need to download and read the Using Zend Framework 2 e-book.

Hello World

This sample is based on Zend Skeleton Application and illustrates Chapter 4, Chapter 5 and Chapter 6 of the book. It shows how to:

  • Register controllers
  • Create controller actions
  • Use layouts and switch them
  • Generate URLs with the Url controller plugin and the Url view helper
  • Create a custom route type
  • Create own view helpers

Form Demo

This sample is based on the Hello World sample and illustrates Chapter 7 "Collecting User Input with Forms" and Chapter 8 "Advanced Usage of Forms". It shows how to:

  • Create a form model
  • Use the form model in a controller
  • Render the form with special form view helpers
  • Use form security elements (CAPTCHA, CSRF)
  • Upload files with forms

Blog

This sample is based on the Hello World sample and illustrates Chapter 9 "Database Management with Doctrine". It shows how to:

  • Integrate your web site with Doctrine library
  • Initialize database schema
  • Use entity manager
  • Create entities and define relations between entities
  • Create repositories