What is this?
Let's create a REST API with Mezzio. In this series, you'll learn how to create a REST API from the ground up. We'll use Mezzio as the base framework, Doctrine for the data layer, OAuth2 for authentication and authorization, PHPUnit for automated testing, and several other libraries along the way.
I've created a new bare-bones application starting with the Mezzio Skeleton Application where all the code shown in this series lives. You can install it in your local environment and hack on it all you want. You're also welcome to contribute to the example application via PR. Check it out here:
Mezzio is a micro framework using the middleware pattern. Middleware is a bit of code that sits between a HTTP request and response. I find it quite refreshing after working with the complexities of MVC for many years. Since the PHP community has standardized HTTP requests & responses via PSR-7, dependency injection containers via PSR-11, and the HTTP request handler and middleware interfaces via PSR-15 (among others), PHP has seen growth in modernizing legacy applications using the new tools. Mezzio has taken full advantage of the new standards and serves as the basis for much of that new growth.
I won't go into any more detail. Since you're here, you've probably already chosen Mezzio. If you have any questions at all, please don't hesitate to leave a comment in Disqus below.
Doctrine is a collection of several related packages concerned with the data layer of a PHP application. Doctrine makes it possible to create applications that can run on any supported database engine via the Database Abstraction Layer (DBAL) and makes working with data objects refreshingly easy with the Object Relational Mapper (ORM).
OAuth2 is the current standard framework for building authorization into an application. The Mezzio framework comes with an implementation of OAuth2 using the wonderful OAuth2 Server implementation from the League of Extraordinary Packages. That implementation comes out of the box with a basic PDO setup for the data layer. In this series, I'll show how we can use Doctrine instead.
The next post in this series gets into setting up a good application foundation with automated testing.
Series: Mezzio Example
- Mezzio Example: Introduction
- Mezzio Example: Functional Testing