Support the ongoing development of Laravel.io →
Article Hero Image

Snippets - Introducing Laravel Snippets

17 Sep, 2026 4 min read

Photo by Natalia Blauth on Unsplash

Laravel Snippets 0

Laravel Snippets is a static rendering of the Laravel 13.x documentation where every PHP code block is runnable. PHP 8.5 boots inside a web worker, loads a Laravel 13 bundle, and executes each example directly in your browser. No server runs any code.

Laravel Snippets 1

To try it right away, head over to this link.

Laravel Snippets is a demonstration of what PHP.wasm snippets can do, not an official Laravel resource. Many thanks to the Laravel team for their outstanding work and documentation.

The Laravel documentation is a pleasure to read, and it is full of code. But that code sits still. You read ->groupBy(), you picture the shape of the result, and to actually see it you copy the example into a project, adapt it, run it, and only then find out whether your mental picture was right. Between the paragraph and the answer there is a whole round trip.

Two years ago, Run Laravel on your browser with Browser PHP asked how a PHP script could run on the client side. Laravel Snippets is the same question asked again, on a page you already visit every week : what if every example ran where you read it?

Every example runs

Each php fence of the documentation becomes a snippet with a Run button. The output appears under the code, with the colours of dump() and the framework's own error formatting preserved. The first run boots PHP and every run after that is immediate.

Laravel Snippets 2

Laravel Snippets 3

Snippets are editable

The code block is editable in place. Change a value, add a ->map(), run it again, and press reset to return to the documentation's version. The example becomes a small sandbox without leaving the page.

Laravel Snippets 4

A real Laravel underneath

The worker unzips a Laravel 13 framework bundle at boot, so Illuminate\Support\Collection, dump(), Lang::get() and their friends resolve as they would in a project. The bundle also carries a set of models User, Post, Flight, Order because the documentation refers to them constantly and an example that cannot resolve App\Models\User cannot run.

Always current

Laravel Snippets follows the documentation instead of freezing a copy of it. A scheduled workflow mirrors the upstream laravel/docs markdown repository every day. A second one fetches Laravel compiled CSS and fonts every day, so the pages keep the typography of the original. Each successful sync republishes the static site on GitHub Pages.

The report

Once every example is runnable, a second question follows on its own : how many of them actually run?

A workflow answers it. Playwright boots each prerendered page, runs every snippet through the PHP.wasm worker, and records the outcome in one of six buckets: ran-ok, ran-with-stderr, ran-exit-nonzero, worker-error, no-output, never-completed. The sweep runs weekly, and again whenever the runtime or the markdown sources change. The report shows the totals, a per-page rollup, and every single snippet with its input and its output.

Laravel Snippets 5

Two thirds run clean. The remaining third deserves a warning, because a red cell is not a bug in the documentation. There is no database behind the browser, no Stripe key, no Sanctum, no Pennant. And a large share of the code in the documentation was never meant to run at all : a configuration array, a class body without its class. Those blocks fail by design.

Getting started

There is nothing to install.

  1. Check out the Github repository or open the live demo.

  2. Pick a page in the sidebar.

  3. Press Run on any snippet.

  4. Edit the code and run it again.

  5. Open the report to see what currently fails, and where.

Last updated 2 hours ago.
1
Like this article? Let the author know and give them a clap!
mho (MHO) Part time side project full stack web developer | designer Work @ http://capsules.codes

Other articles you might like

Article Hero Image July 28th 2026

The `clamp` Function in PHP 8.6

Introduction The clamp function is a new addition (RFC) to PHP 8.6 (to be released in November 2026)...

Read article
Article Hero Image June 13th 2026

Building a Production MCP Server in Laravel

Spec version notice: This article targets MCP specification version 2025-11-25. The protocol has sh...

Read article
Article Hero Image May 30th 2026

Evals in Laravel: How to Prove Your AI Output Is Actually Good

You shipped the ticket classifier last quarter. It works. The tests are green and they've stayed gre...

Read article

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2026 Laravel.io - All rights reserved.