Skip to content
AXVI BUILD · WRITE · SHIP
Books

Rust for Laravel Developers

How to stop fearing the borrow checker and start writing servers that don't crash

You know Laravel inside out. This book teaches Rust through what you already know: every concept starts from the PHP you'd write, then shows the Rust, then explains why it's different.

About the book

Most Rust books are written either for C++ programmers who need to be told why a garbage collector is nice, or for beginners who need to be told what a loop is. You're neither. You come from a language where memory isn't your problem, types are optional and a request lives for two hundred milliseconds. Rust is built on the opposite assumptions, and that, not the syntax, is what makes the first week hard.

This book is about the mental model.

It starts with how Rust splits the world into data, behaviour and contracts, and why there are no classes. Then it goes through the language chapter by chapter, from variables to async, every time with "in PHP, in Rust" side by side, the reason behind the difference, and the gotchas the official docs don't mention. It ends with an end-to-end orders service on Axum and sqlx: domain logic, errors that turn into proper HTTP codes, a repository, middleware, validation, pagination and a 10 MB Docker image.

What's inside

  • The mental model first: structs, impl and traits instead of classes; composition instead of extends
  • Ownership and borrowing explained with safes, keys and libraries: the two chapters where most people give up
  • Option instead of null, Result and ? instead of exceptions
  • Iterators as Laravel Collections, without the intermediate arrays
  • Threads, Arc<Mutex>, channels, and async with Tokio, and the three ways to accidentally freeze your server
  • A real project: Axum + sqlx + Postgres, JWT auth via extractors, validation, pagination, OpenAPI, graceful shutdown, CI
  • Every chapter ends with exercises and a one-page cheat sheet; every code sample has been compiled and run
  • 36 illustrations, including a crab who has opinions about your borrow checker errors

Who this book is for

Laravel and PHP developers with a couple of years of production experience who want to understand Rust: for a side project, for performance-critical services next to their Laravel app, or for the next step in their career. You don't need C, C++ or any systems programming background.

Free sample

The sample is a 24-page PDF with the opening chapters. The full book is on Leanpub, in PDF and EPUB.

Esc