O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Better PHP Development

Book Description

PHP powers the vast majority of the web today. It is by far the most ubiquitous and accessible mature web language, and welcomes thousands of new developers every day. It is this ease of access that can, admittedly, sometimes give it a bad name - good resources are few and far in between, and the competition is real, driving people to take shortcuts, skip best practices, and learn on-the-fly.

With PHP 7+ came some improvements that make it harder to make mistakes, and 7.2 is making things even safer, even more structured. If you're just getting started with the language (or perhaps youve been using it a while and have learned some bad habits), you're in luck. Not only will it be ever harder to slip up and make mistakes, but content such as this - hand picked from the excellent SitePoint PHP channel - will help you get started the right way.

This collection comprises:

  • How PHP Executes - from Source Code to Render by Thomas Punt
  • Getting to Know and Love Xdebug by Bruno Å kvorc
  • Localization Demystified: Php-Intl for Everyone by Younes Rafie
  • Event Sourcing in a Pinch by Christopher Pitt
  • Disco with Design Patterns: A Fresh Look at Dependency Injection by Reza Lavaryan
  • A Comprehensive Guide to Using Cronjobs by Reza Lavaryan
  • Event Loops in PHP by Christopher Pitt
  • PDO - the Right Way to Access Databases in PHP by Parham Doustdar
  • Vagrant: The Right Way to Start with PHP by Bruno Å kvorc



This book is suitable for beginner- to intermediate-level PHP developers.

Table of Contents

  1. Better PHP Development
  2. Notice of Rights
  3. Notice of Liability
  4. Trademark Notice
  5. About SitePoint
  6. Preface
    1. Conventions Used
  7. Chapter 1: How PHP Executes—from Source Code to Render
    1. Introduction
    2. Stage 1 - Lexing
    3. Stage 2 - Parsing
    4. Stage 3 - Compilation
    5. Stage 4 - Interpretation
    6. Conclusion
  8. Chapter 2: Getting to Know and Love Xdebug
    1. How do I use it?
    2. With modern IDEs and Blackfire, is there even a need for Xdebug?
    3. Let's Try It Out
    4. Xdebug with Vagrant and PhpStorm
    5. Using the Profiler
    6. Forcing Xdebug's Render on Laravel
    7. Conclusion
  9. Chapter 3: Localization Demystified: Php-Intl for Everyone
    1. Installation
    2. Message Formatting
    3. Message Parsing
  10. Chapter 4: Event Sourcing in a Pinch
    1. Common Language
    2. Storing State vs. Storing Behavior
    3. Making Events
    4. Storing Events
    5. Projecting Events
    6. Summary
  11. Chapter 5: Disco with Design Patterns: A Fresh Look at Dependency Injection
    1. Installation
    2. Getting Started
    3. Service Scope
    4. Container Parameters
    5. Disco in Action
    6. Routing
    7. The Front Controller
    8. But How About the Configuration?
    9. Creating a Container Builder
    10. Creating a Response Listener
    11. Conclusion
  12. Chapter 6: A Comprehensive Guide to Using Cronjobs
    1. Terminology
    2. Getting Started
    3. Crontab Files
    4. How Cron Interprets Crontab Files
    5. Cron Permissions
    6. Redirecting Output
    7. Email the Output
    8. Cron and PHP
    9. Task Overlaps
    10. Anacron
    11. Quick Troubleshooting
    12. Wrapping Up
  13. Chapter 7: Event Loops in PHP
    1. Where Things Go To Wait
    2. Life Without An Event Loop
    3. Icicle
    4. ReactPHP
    5. Conclusion
  14. Chapter 8: PDO - the Right Way to Access Databases in PHP
    1. Why not mysql and mysqli?
    2. Verifying the Existence of PDO
    3. Installation of PDO
    4. Beginning with PDO: a High-level Overview
    5. Connecting to your database
    6. Queries
    7. Prepared Statements and Binding Parameters
    8. Binding Values to an IN Clause
    9. Providing Datatypes When Binding Parameters
    10. Conclusion
  15. Chapter 9: Vagrant: The Right Way to Start with PHP
    1. What?
    2. Why?
    3. How?
    4. Hi!
    5. Conclusion