Book Image

Zend Framework 2 Application Development

By : Christopher Valles
Book Image

Zend Framework 2 Application Development

By: Christopher Valles

Overview of this book

<p>Zend Framework 2 has a flexible architecture that lets us build modern web applications and web services easily. It also provides an easy-to-use, high quality component library that is designed to be used the way you want. It's easy to get started and produce a powerful and professional looking website with Zend Framework 2 Application Development. Exploring real life applications, we will explore the Zend Framework 2 components, as well as throwing some light on best practices and design concerns faced when building complex MVC applications.Zend Framework 2 Application Development is a hands-on guide to building your application. We will explore the components of this new version of the framework and discover how to use each component, the options available, and how to get the most from each component. Whilst learning everything you need to know, we’ll even create our own social network. We will also learn to engineer an application using an API-centric approach, broadly used today to build applications that work seamlessly on desktops, mobiles and tablets. We will learn how to filter and validate data, interact with databases to retrieve and store data, handle and manipulate file uploads, interact with other websites, deal with spam, and also protect your APIs using OAuth authentication whilst allowing people from all over the world to interact with your application. Zend Framework 2 Application Development is your guide to everything you need to know to build applications of any size for big and small companies alike, whilst using the right components for the job.</p>
Table of Contents (21 chapters)
Zend Framework 2 Application Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
4
The First Request/Response – Building the User Wall
5
Handling Text Content – Posting Text
6
Working with Images – Publishing Pictures
8
Dealing with Spam – Akismet to the Rescue
Index

The request object


As we said, the request object will encapsulate all the data related to a request and provide the developer with a fluent API to access the data. Let's take a look at the details of the request object in order to understand how to use it and what it can offer to us:

use Zend\Http\Request;

$string = "GET /foo HTTP/1.1\r\n\r\nSome Content";
$request = Request::fromString($string);

$request->getMethod();
$request->getUri();
$request->getUriString();
$request->getVersion();
$request->getContent();

This example comes directly from the documentation and shows how a request object can be created from a string, and then access some data related with the request using the methods provided. So, every time we need to know something related to the request, we will access this object to get the data we need.

If we check the code on Zend\Http\PhpEnvironment\Request.php, the first thing we can notice is that the data is populated on the constructor using the superglobal...