Chapter 15. Command-Line and Web Services

WHAT'S IN THIS CHAPTER?

  • Building command-line services

  • Creating recurring jobs

  • Describing web services with WSDL

  • Building RESTful web services

  • Building a web service with SOAP

There is more to PHP and MySQL than just consumer-facing web sites. They are capable of so much more. To this point, this book has covered using PHP as a Gearman worker and as a tool for rewriting URLs. This chapter explores some more of the less traditional uses of PHP, expanding on topics expressed in previous chapters.

This chapter also talks about using PHP to create web services, which are endpoints for communication between two parties. Those parties can be the application and another server, the application and the user, or even the application and any third party that could benefit from gaining access to some of the application information.

CREATING COMMAND-LINE SCRIPTS

PHP is not the first language that comes to mind when the subject of command-line scripts comes up. Although it's as common to use PHP for this purpose as it is to use other languages, PHP is extremely powerful. This section covers how to create a command-line script using the PHP CLI (Command Line Interface). The chapter focuses mostly on UNIX/Linux; however, many of the concepts do translate well to Windows.

The first step in creating command-line scripts is to create a stand-alone executable file. This was covered in Chapter 11 when you created a dynamic rewrite map. The CLI doesn't care if the filename ...

Get Expert PHP and MySQL® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.