Skip to Main Content
Programming PHP, 4th Edition
book

Programming PHP, 4th Edition

by Kevin Tatroe, Peter MacIntyre
March 2020
Intermediate to advanced content levelIntermediate to advanced
542 pages
12h 22m
English
O'Reilly Media, Inc.
Book available
Content preview from Programming PHP, 4th Edition

Chapter 16. Web Services

Historically, every time there’s been a need for two systems to communicate, a new protocol has been created (for example, SMTP for sending mail, POP3 for receiving mail, and the numerous protocols that database clients and servers use). The idea of web services is to remove the need to create new protocols by providing a standardized mechanism for remote procedure calls, based on XML and HTTP.

Web services make it easy to integrate heterogeneous systems. Say you’re writing a web interface to a library system that already exists. It has a complex system of database tables, and lots of business logic embedded in the program code that manipulates those tables. And it’s written in C++. You could reimplement the business logic in PHP, writing a lot of code to manipulate tables in the correct way, or you could write a little code in C++ to expose the library operations (e.g., check out a book to a user, see when this book is due back, see what the overdue fines are for this user) as a web service. Now your PHP code simply has to handle the web frontend; it can use the library service to do all the heavy lifting.

REST Clients

A RESTful web service is a loose description of web APIs implemented using HTTP and the principles of Representational State Transfer (REST). It refers to a collection of resources, along with basic operations a client can perform on those resources through the API.

For example, an API might describe a collection of authors and the books ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming PHP, 3rd Edition

Programming PHP, 3rd Edition

Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 9781492054122Errata PageSupplemental Content