Skip to Content
PHP Cookbook, 3rd Edition
book

PHP Cookbook, 3rd Edition

by David Sklar, Adam Trachtenberg
July 2014
Intermediate to advanced
820 pages
17h 6m
English
O'Reilly Media, Inc.
Content preview from PHP Cookbook, 3rd Edition

Chapter 22. Performance Tuning

Introduction

PHP is pretty speedy. Usually, the slow parts of your PHP programs have to do with external resources—waiting for a database query to finish or for the contents of a remote URL to be retrieved. That said, your PHP code itself may not be as efficient as it could be. This chapter is about techniques for finding and fixing performance problems in your code.

There’s plenty of debate in the world of software engineering about the best time in the development process to start optimizing. Optimize too early and you’ll spend too much time nitpicking over details that may not be important in the big picture; optimize too late and you may find that you have to rewrite large chunks of your application.

Optimization doesn’t happen in a vacuum. As you tweak your code, you’re not just adjusting raw execution time—you’re also affecting code size, readability, and maintainability. There are always circumstances that demand screamingly fast execution time. More frequently, however, programmer time or ease of debugging is a more valuable commodity. Try to balance these concerns as you tackle optimization hurdles in your code.

Installing a code accelerator is the best thing you can do to improve performance of PHP. As of PHP 5.5, PHP bundles and builds the Zend OPcache PHP accelerator, but OPcache works for PHP 5.2 and above. This extension is covered in Using an Accelerator.

If your application is still too slow, get started with integrating some easy analysis ...

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

PHP Cookbook, 2nd Edition

PHP Cookbook, 2nd Edition

Adam Trachtenberg, David Sklar
Programming PHP, 4th Edition

Programming PHP, 4th Edition

Kevin Tatroe, Peter MacIntyre
MySQL Cookbook, 4th Edition

MySQL Cookbook, 4th Edition

Sveta Smirnova, Alkin Tezuysal

Publisher Resources

ISBN: 9781449363741Errata