Chapter 8. PHP and Friends
PHP is a wonderful language—it is robust and flexible and friendly. By friendly, I mean that it can freely integrate with libraries built by outside sources. This is in keeping with an important and ever-present caveat in the open source development world: not reinventing the wheel. There are many different libraries out on the Web that can integrate well with PHP and are actually also developed in PHP. In this chapter, we will look at three different PHP add-on libraries and discuss how to use existing tools to enhance our PHP web development.
The three libraries we’ll cover are all PHP object-oriented-based, so be sure you have read Chapter 6 in this book or are familiar with object-oriented programming before going too far into the examples. These three libraries were chosen because they are helpful for performing some of the top tasks in a modern web-based application: sending email messages or Short Message Service (SMS) text messages, generating PDF forms, and generating graphical data reports (e.g., pie charts and bar charts).
Email/SMS Generation
PHP has a built-in mail function called mail()
. This will send
out Simple Mail Transport Protocol (SMTP) mail to the world. The mail
function is quite simplistic and basic, so it usually is not the best
choice, on its own, for heavier email tasks. It’s tricky to send email
messages with attachments, for example.
The PHP library, called PHPMailer, is just what the doctor ordered to fill the gap. It is object-based ...
Get PHP: The Good Parts 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.