Building RESTful Web Services in PHP7


Here is the book I have written recently on RESTful web services in PHP 7. The title is Building RESTful Web Services in PHP7 and is available on Amazon. You are probably wondering that why another PHP book. Why about RESTful web services. Many people consider RESTful web services as hitting a URI and getting JSON in response. However, this is a misconception. RESTful web service is more than that. And when it comes to Building RESTful web services then there  are numerous important things to consider.

Although there are already books on PHP and RESTful web services, this book is important because PHP and its ecosystem has evolved. “PHP7” in the title is to tell that we are talking about modern tools and ecosystem of PHP. Let me provide you detail of book in structured way. Let’s discuss different aspects of the book one by one.

Who is this book Useful for?

  • Anyone who have some basic PHP knowledge and want to build RESTful Web Service.
  • Developers who know basic PHP and have developed some basic dynamic website.
  • Developers who know basic PHP and have developed some basic dynamic website.
  • Developers who have learned PHP and worked mostly in Open source CMS like WordPress etc.
  • Developers who have used modern frameworks but not sure about critical pieces required to build RESTful API.
  • A seasoned PHP Developer, have created very basic API that returns data but want to make himself familiar with how it should be done according to REST standards and how it will work when authentication etc comes in and how to write tests for it.

What will Reader Learn?

  • REST API architecture and its benefits
  • How to write RESTful API web services in PHP7
  • To address security related issues in a REST API
  • Importance of automated testing and to write tests for API endpoints
  • Will be introduced to Micro-services architecture
  • Will understand security flaws in our API endpoints and tackle them effectively
  • The working of Lumen micro-framework and writing RESTful web services in it

Content of Book, Chapter by Chapter:

Chapter 1 RESTful web services, Introduction and Motivation:

This chapter is about introduction to Web Services, REST Architecture, RESTful Web Services, its comparison to other Web Services. HTTP Verbs, RESTful endpoints. It also explains RESTful web services concept by the use of Blog example and then talk about Response format and Response Code.

Chapter 2, PHP7, To Code It Better :

This chapter includes new features or changes on PHP7, which we will either use in this book or which are very important and worth discussing. As new features include features related to generators as well so introduced generators to user. Although generators were there already but rarely people use it. So this chapter also tells us about generators with examples.

Chapter 3, Creating RESTful Endpoints :

This chapter is about creating REST API endpoints for CRUD operations of a blog post in Vanilla PHP. Will also tell manual way of testing API endpoints through a REST client named as Postman.

Chapter 4, Reviewing Design Flaws and Security Threats :

In this chapter we will review what we have built in Chapter 3 and will highlight problems and flaws in it so that we can later improve that. It will include some security flaws as well. Some of the flaws and security threats in our application also fixed in this chapter while told about some of threats solution but not solved in this chapter but pointed towards open source package.

Chapter 5, Load and Resolve with Composer, an Evolutionary:

This chapter is about an evolutionary tool in PHP eco-system that is composer.This is not just an autoloader or package installer but a dependency manager. So one knows more about composer in this chapter.

Chapter 6, Illuminating RESTful Web Services with Lumen:

In this chapter we will introduce a micro-framework named Lumen. And will rewrite our RESTful web services endpoints in this micro-framework and will review how this tool will significantly improve our development speed as well as application structure.

In this chapter, users can first understand the Lumen framework, its components and then its usage to create RESTful web services’ endpoints.

Chapter 7, Improving RESTful web services:

This chapter will improve what is done in chapter 6 and we will learn and improve lot of stuff. User will create authentication, will make Transformer to separate how JSON structure should look like. Also user will improve web service in terms of security and will also learn about SSL.

Chapter 8, API Testing – Guards on the Gate:

This chapter introduces the need of Automated Tests. Will introduce different type of tests and then focus on API testing and teach user an automated testing framework named CodeCeption and will then write API tests in that testing framework.

Chapter 9, Microservices – An introduction

This chapter is about micro-services architecture. So we will understand and see benefits and challenges of Micro-services and will look into some of possible solutions or trade-offs. Introducing a new topic at the end of book normally doesn’t make sense. However, here this chapter point user towards Micro-services architecture that seems like the logical next step about how RESTful web services should be organized.

 

This is how I could present the content of the book. Feel free to let me know of your opinion. If you liked the book and want to buy then you can buy it from amazon: