Book Image

Zend Framework 2 Cookbook

By : Josephus Callaars, [email protected]
Book Image

Zend Framework 2 Cookbook

By: Josephus Callaars, [email protected]

Overview of this book

Zend Framework 2 is the latest creation of World Wide Web infrastructure company Zend Technologies Ltd. This new PHP framework comes with tons of features and an attractive way of creating applications. Not only is the overall usability of the technology much better, but it also makes your applications more testable, something that is often overlooked. "Zend Framework 2 Cookbook" will show you how applications are set up in Zend Framework 2 and how you can develop successfully in this massive framework. You will master features like Modules, Views, Controllers, and Authentication. The book also discusses the Event Manager, unit testing, and how to optimize your application. The book begins with a discussion about setting up Zend Framework 2, and you will also look at how the framework itself works. By the end of this book, you will be able to create entire secure applications on your own and make sure they are tested and optimized for performance as well. You will learn about sending and receiving e-mails, translation and localization of the application, and how to set up the framework on a Linux web server. You will also learn how to display data from the application to the user by using different display strategies and renderings. The creation of modules will also be discussed. Then, you will move on to look at how to authenticate users and make sure the developer knows how to pick the best method available. Unit testing, debugging, and enhancing the performance will also be covered in this book. "Zend Framework 2 Cookbook" is a perfect book for anyone who wants to start developing with Zend Framework 2.
Table of Contents (17 chapters)
Zend Framework 2 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a new module


The core of the Zend Framework 2 library is modular and everything is based around a module based system. That's why we will explain this thoroughly in this recipe, so that we can use it in its best way possible.

Getting ready

We will be using the Zend Framework skeleton application for creating new modules. As a reminder, the Zend Framework 2 skeleton application can be found at https://github.com/zendframework/ZendSkeletonApplication.

How to do it…

Creating a new module is like starting a new drawing, it is exciting and fun to create a new functionality, but there are always rules we need to obey. In this recipe we will discuss what the rules are for setting up a new module.

Creating the Module.php

We can start off with just a simple class file (that is, /module/Sample/Module.php) in the right namespace (Sample) with nothing in it, which is basically the only requirement there is for the module.

<?php

  namespace Sample;

  class Module {}

We can add the following method...