Loco for Laravel Developers
Build a blog in Rust from scratch: from the first command to a Docker deploy
Loco is the Rust framework that feels like Laravel: generators, models, migrations, workers, mailers, a scheduler. This book builds a complete blog with it, one step at a time, and every step is a git tag you can check out.
About the book
Framework docs show you each feature on its own. Real work is where features meet: the admin form that has to show validation errors, the email that has to go out exactly once, the cache that has to forget a page when a post changes, the container that has to shut down without losing a job.
This book builds one real application end to end. You start with loco new and finish with a blog running in Docker on Postgres: public pages, tags, authors and login, a hand-written HTMX admin, image uploads, background jobs and emails, scheduled tasks, RSS and a sitemap, a page cache that took the home page from about 1,300 to about 25,000 requests per second, and a test suite of over a hundred tests.
Every command, output and error in the book comes from actually building that blog on Loco 1.2, and every step has been rebuilt and re-tested on Loco 1.3.1. Where Loco has rough edges (generator bugs, defaults that silently do nothing, places where the docs describe the old 0.x) the book says so and shows the workaround. Every chapter compares the Loco way with the Laravel way you already know.
What's inside
- Setup in Docker, the generated app, and a folder-by-folder map to Laravel
- SeaORM instead of Eloquent: entities,
ModelandActiveModel, relations, many-to-many without N+1 - Tera 2 templates instead of Blade, and what changed from Tera 1
- Cookie-based login, a
CurrentUserextractor, and an admin area with HTMX and proper 422 forms - Uploads with content checks, background workers, mailers (and the escaping trap in mail templates)
- Tasks, the scheduler, and why background jobs get lost without a persistent queue
- Caching, ETags and a real load test; request, model, worker and snapshot tests
- Production: Dockerfile, docker-compose with Postgres, migrations, graceful shutdown
- 13 steps, each a tag in the companion repository; exercises and a cheat sheet in every chapter
Who this book is for
Laravel developers who know Rust basics (the first book, Rust for Laravel Developers, covers exactly that) and want to build real web applications in Rust with the productivity they're used to.
Free sample
The sample is a 52-page PDF with the first steps of the blog. The full book is on Leanpub, in PDF and EPUB.