Books

Best PHP Books for PHP 8 Developers: Laravel, Symfony, Testing

This post contains affiliate links. If you buy through them, we may earn a small commission at no extra cost to you. Learn more.

Most lists of the best PHP books still assume the language stopped moving around version 7, and that’s the assumption that ages a PHP book fastest. PHP 8.1 added enums, 8.2 deprecated dynamic properties, 8.4 brought property hooks and 8.5 added a pipe operator, so a book printed in 2020 can teach code that now prints deprecation warnings. You do not need the newest book on every shelf. You do need to know which version each one stops at.

Original content from computingforgeeks.com - post 179165

This guide picks ten PHP 8 books across four jobs: learning the language, writing object-oriented PHP with patterns, working in Laravel or Symfony, and testing with PHPUnit. For each one we name the PHP or framework version it was written against, who it suits and when to skip it. The behavior described here was checked against PHP 8.5.4 on an Ubuntu 26.04 workstation in October 2026. Editions, page counts and price bands came from the Amazon catalog the same week.

How the best PHP books map to your next step

The right first PHP book depends on whether you’re learning the language or upgrading how you write it, because the beginner books and the PHP 8 craft books barely overlap. PHP Crash Course spends 16 of its 31 chapters on the language, forms and sessions before it reaches a class. The Zandstra patterns book assumes you have written classes for years. Match the book to the job you have this month:

If PHP is not installed yet, set it up before the first chapter, because every book here expects you to type code and run it. Our guides to installing PHP on Ubuntu and PHP on Rocky Linux and AlmaLinux get a current 8.x CLI running in a few minutes. The LAMP stack on Ubuntu 26.04 adds the Apache and MariaDB pieces the beginner books build on.

How we checked each book against PHP 8.5

Every edition, binding, page count and publication date below comes from the Amazon catalog API, pulled on October 28, 2026. Every version claim comes from the publisher page, the blurb or the companion repository. Where a publisher does not say which PHP or framework version a book targets, we say so instead of guessing. Two picks have a Kindle listing with a separate ASIN, so we linked the paperback each time and matched the cover to that edition.

We did not read all ten cover to cover in a week, and we will not pretend we did. What we tested is the thing that decides whether book code still runs. We took idioms that show up all over PHP 7-era books and ran them on PHP 8.5.4, then ran the newer features each book does or does not cover. The table pulls it together.

BookEdition, yearWritten againstLevelBest for
PHP Crash Course1st, 2025PHP 8 (enums chapter; minor version not stated)BeginnerFirst language book
PHP & MySQL (Duckett)1st, 2022No enums or readonly in its contents (updates page adds 8.1+ notes)BeginnerVisual learners, CMS project
Learning PHP, MySQL & JavaScript7th, 2025Not stated by the publisherBeginnerFull-stack basics with React
PHP 8 Objects, Patterns, and Practice Vol 17th, 2024PHP 8.3IntermediateOOP and design patterns
PHP 8 Objects, Patterns, and Practice Vol 27th, 2025PHP 8.3IntermediateComposer, testing, CI, Docker
PHP Cookbook1st, 2023PHP through 8.2IntermediateDesk reference
Laravel: Up & Running3rd, 2023Laravel 10IntermediateLaravel from the ground up
Practical PHP APIs with Symfony1st, 2025Not stated by the publisherIntermediateSymfony API design
Modern Testing with PHP1st, 2026PHPUnit (version not stated)IntermediateTesting a real project
Clean Code in PHP1st, 2022PHP 8.0 and aboveIntermediateCode quality and team rules

Read the third column as a ceiling, not a defect. A book written against PHP 8.2 still teaches correct PHP on 8.5, because the newer releases mostly add syntax and deprecate old habits rather than break working modern code. What it cannot do is show you property hooks or the pipe operator, so you fill that gap from the release notes.

What happens when older book code runs on PHP 8.5

Older PHP books do not fail on PHP 8.5 so much as they get noisy. That noise is the thing to understand before you buy a cheap used edition. We wrote a small file with four idioms that were normal in PHP 7 books: a constructor parameter typed Logger $logger = null, a property assigned without being declared, ${name} inside a string and a call to utf8_encode(). This is the file, unchanged:

<?php
// Idioms common in PHP 7-era book code, run on a current PHP.

class Logger {}

class Invoice
{
    public function __construct(Logger $logger = null)
    {
        $this->logger = $logger;
    }
}

$invoice = new Invoice();
$name = "World";
echo "Hello ${name}\n";
echo utf8_encode("caf\xe9"), "\n";

We ran it with every error level switched on and the default php.ini ignored, so nothing in the local config could hide a warning:

php -n -d error_reporting=E_ALL -d display_errors=stderr -d log_errors=0 old-book-idioms.php

PHP 8.5.4 ran the whole script and printed the right result, but it raised four deprecations on the way:

Deprecated: Invoice::__construct(): Implicitly marking parameter $logger as nullable is deprecated, the explicit nullable type must be used instead in /tmp/engine-job-769/php-check/old-book-idioms.php on line 8
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /tmp/engine-job-769/php-check/old-book-idioms.php on line 16
Deprecated: Creation of dynamic property Invoice::$logger is deprecated in /tmp/engine-job-769/php-check/old-book-idioms.php on line 10
Hello World
Deprecated: Function utf8_encode() is deprecated since 8.2, visit the php.net documentation for various alternatives in /tmp/engine-job-769/php-check/old-book-idioms.php on line 17
café

The order is the interesting part. Line 8 and line 16 are reported before line 10, because PHP flags those two while it compiles the file, before a single statement runs. The dynamic property and the utf8_encode() call only complain when execution reaches them. So a project can look clean in a quick test and still flood its logs in production. Each fix is one line:

  • Nullable parameter: write ?Logger $logger = null so the null is explicit.
  • Dynamic property: declare private ?Logger $logger on the class before assigning it.
  • String interpolation: use {$name} in place of ${name}.
  • Encoding: call mb_convert_encoding($s, 'UTF-8', 'ISO-8859-1') in place of utf8_encode(); it needs the mbstring extension (the php8.5-mbstring package on Ubuntu 26.04), which php -n does not load.

None of those is hard, but a book that teaches the old forms trains you to write code PHP has already marked for removal, and you pay for that habit on every upgrade.

The second file goes the other way. It uses one feature from each release from 8.1 to 8.5, so you can see where each book’s coverage stops:

<?php
declare(strict_types=1);

enum Status: string            // PHP 8.1
{
    case Draft = 'draft';
    case Live = 'live';
}

readonly class Money           // PHP 8.2
{
    public function __construct(public int $cents) {}
}

class Config
{
    const string ENV = 'prod';  // PHP 8.3 typed class constant
}

class User
{
    public string $email {     // PHP 8.4 property hook
        set => strtolower($value);
    }
}

$u = new User();
$u->email = '[email protected]';

$slug = '  Best PHP Books  '
    |> trim(...)               // PHP 8.5 pipe operator
    |> strtolower(...)
    |> (fn($s) => str_replace(' ', '-', $s));

echo Status::Live->value, PHP_EOL;
echo (new Money(4999))->cents, PHP_EOL;
echo Config::ENV, PHP_EOL;
echo $u->email, PHP_EOL;
echo $slug, PHP_EOL;

Run it with the plain CLI:

php php8-features.php

Each line of output proves one release’s feature worked, and the property hook lowercased the email on assignment without a setter method:

live
4999
prod
[email protected]
best-php-books

Map that file onto the table and the books sort themselves. The seventh edition of Zandstra covers everything down to the typed class constant, and the Cookbook stops at the 8.2 line. None of the books whose publisher states a version goes past PHP 8.3, and every book here that teaches the language was printed before PHP 8.5 shipped the pipe operator. Those two features are short enough to learn from the PHP 8.5 release page, and that is a better use of a book budget than waiting for an eighth edition.

1. PHP Crash Course

This is the beginner pick because it is the one beginner book here built around how PHP is written today, with Composer and enums in the main path.

PHP Crash Course by Matt Smith book cover, No Starch Press
PHP Crash Course, 1st Edition by Matt Smith. Image: No Starch Press.

Matt Smith fills 728 pages with 31 chapters in six parts. It starts with strings and arrays, moves through sessions, a shopping cart and authentication, then covers object-oriented PHP and a database section built on PDO. The middle of the book sets it apart: Composer gets its own chapter, templates move to Twig, and enumerations sit next to static methods. A beginner picks up the PHP 8 toolchain instead of the include-everything style older books start with. Smith is a senior lecturer at Technological University Dublin, and the pacing shows it, with setup appendices for Windows, macOS, Linux and the Replit online editor.

Working PHP developers will find the first half slow, and there is no chapter on PHPUnit. The No Starch page does not name the PHP minor version it targets. It was around $49 against a $69.99 list price when we checked, with Amazon showing only a few copies left.

2. PHP & MySQL: Server-side Web Development

Jon Duckett’s book is the cheapest strong beginner pick, and it had the best Amazon sales rank of any book on this list when we checked.

PHP and MySQL Server-side Web Development by Jon Duckett book cover, Wiley
PHP & MySQL: Server-side Web Development by Jon Duckett. Image: Wiley.

Its 17 chapters and 672 pages build toward one project, a content management system with member accounts, and along the way it covers sessions, error handling, SQL, dependency injection and namespaces. Duckett also wrote the bestselling HTML & CSS and JavaScript & jQuery books, so readers who learned the front end from those will find the same author teaching the server side. The code ships as a zip from the companion site rather than a Git repository.

The trade-off is coverage. It came out in February 2022, three months after PHP 8.1, but its contents list no enums or readonly properties, and the companion site’s updates page carries notes for PHP 8.1 and later. Pick something newer if you want PHP 8.1+ syntax from day one. It was around $27 (list $45) when we checked.

3. Learning PHP, MySQL & JavaScript, 7th Edition

Robin Nixon’s book covers the whole classic web stack in one volume, so it suits the reader who wants to build a site rather than master a language.

Learning PHP, MySQL and JavaScript 7th Edition by Robin Nixon book cover
Learning PHP, MySQL & JavaScript, 7th Edition by Robin Nixon. Image: O’Reilly Media.

The seventh edition came out in February 2025 at 652 pages. Its blurb lists PHP with PDO, MySQL, JavaScript, CSS, HTML5, React and jQuery, plus cookies, sessions, security and Ajax, and it ends with a social networking project that ties them together. That breadth is the selling point: you see how a form posts to PHP, how PHP queries MySQL and how JavaScript updates the page, all in one place.

The breadth is also the cost, since PHP gets a fraction of the pages, and the book’s description doesn’t say which PHP 8 release the examples target. It still lists jQuery, which few new projects pick today. A reader who already knows front-end work and only needs PHP gets more from the Crash Course. It was around $41 (list $59.99) when we checked.

4. PHP 8 Objects, Patterns, and Practice, Volume 1

This is the book that turns someone who writes PHP into someone who designs PHP, and the seventh edition is the only patterns book here updated for PHP 8.3.

PHP 8 Objects, Patterns, and Practice Volume 1 Seventh Edition by Matt Zandstra book cover
PHP 8 Objects, Patterns, and Practice: Volume 1, Seventh Edition by Matt Zandstra. Image: Apress.

Matt Zandstra split the seventh edition into two volumes, and Volume 1 (652 pages, December 2024) holds the language and the patterns. It covers class declarations, inheritance and reflection, then design principles and the classic, enterprise and database patterns, with PHP 8 additions such as readonly classes, enumerations and typed class constants worked into the examples. In our feature file, that’s everything up to the 8.3 line, the highest version any publisher on this list states.

It is the wrong book while you are still learning loops and arrays, because it assumes working PHP and moves fast. Amazon also sells a Kindle edition under a different ASIN, so check you’re on the paperback if you want print. It was around $27 (list $44.99) when we checked, a low price for what it covers.

5. PHP 8 Objects, Patterns, and Practice, Volume 2

Volume 2 is the practice half of the title, and it’s where Zandstra covers the tooling that decides whether a PHP project survives its second developer.

PHP 8 Objects, Patterns, and Practice Volume 2 Seventh Edition by Matt Zandstra book cover
PHP 8 Objects, Patterns, and Practice: Volume 2, Seventh Edition by Matt Zandstra. Image: Apress.

Published in July 2025 at 365 pages and also written against PHP 8.3, it covers Git, Composer, testing both new and legacy code, Selenium for browser tests, and continuous integration including GitHub Actions. The seventh edition adds chapters on Docker, Ansible, refactoring tools and PHP on the command line. If containers are new to you, our Docker book picks go deeper than one chapter can.

It’s the best single book for a developer who knows PHP but has never worked on a team codebase, since its subjects are tools rather than the patterns in Volume 1. For a dedicated PHPUnit book, go to pick 9, because testing here shares the pages with Git, CI and deployment. It was around $31 (list $44.99) when we checked.

6. PHP Cookbook

Eric A. Mann’s cookbook is the desk reference for working developers, organised as problems with modern solutions instead of chapters you read in order.

PHP Cookbook Modern Code Solutions by Eric A. Mann book cover, O'Reilly
PHP Cookbook: Modern Code Solutions for Professional Developers by Eric A. Mann. Image: O’Reilly Media.

This 2023 book (431 pages) is a fresh start, not a fourth edition of the old O’Reilly cookbook, and it covers PHP through version 8.2. The recipes span functions and objects, the type system, encryption, error handling, debugging, performance, the package and extension ecosystem, and command-line as well as web applications, with a security slant that shows in topics like file handling. It’s the book you open when you know what you want to do and need the PHP 8 way to do it.

As a first book it fails, because recipes assume you can place them in a program yourself. It stops at 8.2, so typed class constants and anything newer come from the release notes. It was around $32 (list $65.99) when we checked, with stock running low.

7. Laravel: Up & Running, 3rd Edition

This is still the best structured introduction to Laravel in print, even though the framework has moved three major versions past it.

Laravel Up and Running 3rd Edition by Matt Stauffer book cover, O'Reilly
Laravel: Up & Running, 3rd Edition by Matt Stauffer. Image: O’Reilly Media.

Matt Stauffer revised the book for Laravel 10 in this third edition, a 569-page printing from late 2023. It covers Blade, request validation, the Eloquent ORM and the request lifecycle, then PHPUnit with Mockery and Dusk for tests. Later chapters handle JSON APIs, queues and events, and first-party packages such as Scout, Passport and Cashier. Stauffer teaches Laravel and hosts The Laravel Podcast, and the book explains why each piece exists rather than only how to call it, which is what keeps it useful across versions.

Weigh the version gap before you buy. Laravel 10 stopped getting security fixes on February 4, 2025, and the current release is Laravel 13, which came out on March 17, 2026 and needs PHP 8.3 or newer. Concepts carry over, but the application skeleton and starter kits changed in later releases, so read it with the Laravel release notes open. Readers who want copy-and-run steps for Laravel 13 will hit mismatches. It was around $38.50 (list $59.99) when we checked.

8. Practical PHP APIs with Symfony

Symfony is badly served by print right now, and this short Apress pocket guide is one of the few recent trade books on it, aimed at one job: designing an API.

Practical PHP APIs with Symfony by Nacho Colomina Torregrosa book cover, Apress
Practical PHP APIs with Symfony by Nacho Colomina Torregrosa. Image: Apress.

Nacho Colomina Torregrosa’s book (November 2025, 176 pages on Amazon’s listing) builds an operation-oriented API: a single endpoint that dispatches operations, wired with dependency injection, secured with authentication and backed by Symfony Messenger for asynchronous work. It assumes you already know Symfony, so it skips the framework tour and goes straight to the design decisions.

The publisher’s description doesn’t name the Symfony or PHP version it was written for, and that matters because Symfony 8.1 needs PHP 8.4 while the 7.4 LTS branch runs on PHP 8.2. For a first Symfony introduction, the official Symfony documentation does the job better than the few books in print. It was around $18 (list $29.99) when we checked, the cheapest pick here.

9. Modern Testing with PHP

Mauro Chojrin’s book is the newest on this list and the only one written entirely about testing PHP, which is the skill most self-taught PHP developers are missing.

Modern Testing with PHP PHPUnit book by Mauro Chojrin cover, Apress
Modern Testing with PHP: A Roadmap to Applying PHPUnit to Your Projects by Mauro Chojrin. Image: Apress.

Published in April 2026 at 200 pages, it lays out a roadmap for bringing PHPUnit into an existing project: installing the tools, moving from manual checks to automated tests, then test-driven development and acceptance-test-driven development. It stays framework-agnostic, so the same approach works whether your code runs on Laravel, Symfony or a homegrown framework from 2014.

The listing doesn’t say which PHPUnit version the examples use, and that matters more than usual: PHPUnit 13 needs PHP 8.4 or newer and PHPUnit 12 needs 8.3, so an older production PHP decides which major you can install. At 200 pages it is a roadmap, not a reference, and developers who already practise TDD daily will find little new. It was around $49.99 when we checked, with no discount showing.

10. Clean Code in PHP

Carsten Windler and Alexandre Daubois wrote the book a PHP team lead hands to new hires, about the habits that keep a codebase readable after the original author leaves.

Clean Code in PHP by Carsten Windler and Alexandre Daubois book cover, Packt
Clean Code in PHP, 1st Edition by Carsten Windler and Alexandre Daubois. Image: Packt Publishing.

The 2022 book (264 pages) covers clean code principles, code quality metrics, testing basics, continuous integration, design patterns, team guidelines and documentation, and its companion repository lists PHP 8.0 and above as the requirement. When the book was written, Windler was a lead PHP engineer and Daubois a Symfony developer at SensioLabs, so the advice comes from production teams rather than a classroom.

It’s a habits book, so its PHP 8.0 baseline ages more slowly than a syntax book would. Solo developers writing small scripts can pass, since most of its team process advice will not apply. Amazon also lists a Kindle edition separately; the paperback was around $39 when we checked.

Why the support window matters more than the cover date

A PHP book’s useful life is set by the PHP branch it targets, because that branch is what your production server will run while you use the book. PHP keeps each release in active support for two years and security support for two more, according to the official supported versions page, so these dates tell you how long a book’s version stays relevant:

  • PHP 8.1: end of life since December 31, 2025, which retires any book that stops here for new production work.
  • PHP 8.2: security fixes until December 31, 2026, the ceiling of the PHP Cookbook.
  • PHP 8.3: security fixes until December 31, 2027, the version both Zandstra volumes target.
  • PHP 8.4: security fixes until December 31, 2028, and the minimum for PHPUnit 13 and Symfony 8.1.
  • PHP 8.5: released November 20, 2025, with security fixes until December 31, 2029.

When a book’s version is out of support, it isn’t worthless, but you’ll be translating as you read, and the deprecations in our capture are exactly what that translation looks like. Servers stuck on older branches are a separate problem: our write-up on patching end-of-life PHP branches covers what happens when an application can’t move. For the database half of a PHP stack, the MySQL and MariaDB book list pairs well with any pick here, and the wider best programming books guide covers the other languages.

Common misconceptions about learning PHP from books

Three beliefs come up again and again when people ask which PHP book to buy, and each one leads to a worse choice:

  • “A PHP 7 book is fine because PHP is backward compatible.” The code mostly runs, but our test printed four deprecations from four ordinary lines, and a deprecation is PHP’s notice that the feature is scheduled for removal.
  • “Learn Laravel first and pick up PHP along the way.” Framework books assume you can read classes, closures and namespaces without stopping, so a Crash Course or Duckett first makes Stauffer’s book read twice as fast.
  • “Testing is something you add later.” Most of the intermediate books here (Zandstra Volume 2, Stauffer, Windler and Daubois, Chojrin) treat tests as part of design, and adding PHPUnit to a codebase that was never written for it is the exact problem Modern Testing with PHP was written to solve.

If you buy two books, make one a language book that matches your level and the other a practice book, either Zandstra’s Volume 2 or Chojrin’s testing book. That pairing covers both how to write PHP 8 and how to keep it working, and the release notes cover property hooks and the pipe operator, which none of the books that state a version reaches.

Keep reading

Best Machine Learning Books (2026): Textbooks, Python, Free PDFs AI Best Machine Learning Books (2026): Textbooks, Python, Free PDFs Best C++ and C Programming Books for 2026: Beginner to Advanced Books Best C++ and C Programming Books for 2026: Beginner to Advanced Install GitHub CLI (gh) on Linux, macOS, and Windows Programming Install GitHub CLI (gh) on Linux, macOS, and Windows Best Networking Books: TCP/IP, Routing and Troubleshooting Books Best Networking Books: TCP/IP, Routing and Troubleshooting Best AI Agent Books for 2026: Agentic AI, MCP and Multi-Agent Systems AI Best AI Agent Books for 2026: Agentic AI, MCP and Multi-Agent Systems Best CUDA Books for GPU Programming, With Code Tested AI Best CUDA Books for GPU Programming, With Code Tested

Leave a Comment

Press ESC to close