Book Image

PHP 7 Programming Blueprints

By : Jose Palala, Martin Helmich
Book Image

PHP 7 Programming Blueprints

By: Jose Palala, Martin Helmich

Overview of this book

When it comes to modern web development, performance is everything. The latest version of PHP has been improvised and updated to make it easier to build for performance, improved engine execution, better memory usage, and a new and extended set of tools. If you’re a web developer, what’s not to love? This guide will show you how to make full use of PHP 7 with a range of practical projects that will not only teach you the principles, but also show you how to put them into practice. It will push and extend your skills, helping you to become a more confident and fluent PHP developer. You’ll find out how to build a social newsletter service, a simple blog with a search capability using Elasticsearch, as well as a chat application. We’ll also show you how to create a RESTful web service, a database class to manage a shopping cart on an e-commerce site and how to build an asynchronous microservice architecture. With further guidance on using reactive extensions in PHP, we’re sure that you’ll find everything you need to take full advantage of PHP 7. So dive in now!
Table of Contents (15 chapters)
PHP 7 Programming Blueprints
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
4
Build a Simple Blog with Search Capability using Elasticsearch

Implementing the REST service


In this chapter, you will begin implementing the actual user profile service. As a first step, we will design the RESTful API of the service and then continue by implementing the designed API endpoints.

Designing the service

Now it is time to get to the actual task that we want to implement in this chapter. In this chapter, you will develop a RESTful Web Service using the Slim framework and MongoDB to access and read user profiles. In short, one of the first steps that you should take when designing a REST Web Service is to think about the resources that you want to offer to your users.

Tip

Keeping RESTful Be sure to design around resources whose state you modify with HTTP verbs such as POST, PUT, and DELETE. I've often seen HTTP APIs being developed around procedures, not resources, that end up in URLs such as POST /users/create or POST /users/update that resemble more of an RPC-based API design.

The table that follows shows the resources and operations that we...