Best Practices for Documenting Laravel Code
Laravel relies on PHP features and framework conventions, so a method’s signature (its name, parameters, and return type) does not always show…
When you maintain a Laravel package, developers rely on your documentation to install, configure, and use it. A documentation builder turns your written content into a website. A static-site generator, for example, converts files such as Markdown into HTML, CSS, and JavaScript that you can host separately from your Laravel package.
If your contributors already use PHP and Laravel, Jigsaw is a strong place to start. It supports Markdown and Laravel’s Blade template language, and it outputs static files. Starlight, VitePress, and Docusaurus fit different needs and bring their own toolchains. You should pick a builder based on what your documentation needs to do and which tools your contributors can maintain.
Most package documentation pairs human-written guides with reference material. Guides walk readers through installation, configuration, examples, troubleshooting, and upgrades. Reference material lists code symbols or HTTP endpoints, so you often generate it with a separate tool.
For PHP classes and functions, phpDocumentor reads your source code and DocBlock comments to build an API reference of the code’s public features. For HTTP endpoints in a Laravel app, Scribe and Scramble generate API documentation. You can add those reference pages to a guide site, though package users still need written explanations and examples.
Start by listing the pages your package needs. If readers mainly need instructions and examples, pick a documentation-site builder. Add a code or endpoint reference generator only when that reference solves a separate problem.
Contributors maintain a documentation site more easily when they can edit pages, preview changes, and publish updates using tools they already know. Jigsaw fits contributors who work with PHP. Other builders offer documentation features through JavaScript or Python toolchains.
| Builder | Good fit when | Trade-off |
|---|---|---|
| Jigsaw | Contributors know PHP and want to write Markdown inside Blade layouts. Its documentation starter gives you a starting point, and Jigsaw outputs static files. | Jigsaw requires PHP 8.2 or later and Composer. You only need Node.js and NPM if you use Vite to compile site assets. Check that the starter and available features cover your navigation and search needs. |
| Starlight | You want a documentation-focused site with built-in search, navigation, translations, and code highlighting. | Starlight runs on Astro and uses a JavaScript package manager, which adds a second toolchain to a PHP-focused project. |
| VitePress | Contributors already use Node.js and Vue, or you want to drop Vue components into Markdown pages. | Its current setup guide requires Node.js 22 or later. Check that its current features cover any versioning needs before you pick it. |
| Docusaurus | A larger documentation site needs React or MDX customization, translations, or versioned docs. | When you turn on versioning, Docusaurus keeps snapshots for older releases, which adds build and maintenance work for your team. Docusaurus advises keeping the number of active versions small. |
| MkDocs with Material | Contributors know Python and want to write Markdown documentation. | The maintainers of Material for MkDocs have set an end-of-life date of May 5, 2027. Factor that date into your decision for a new site and check the project’s successor, Zensical, before you commit. |
Jigsaw’s installation instructions list its PHP and Composer requirements. Its starter templates show how Markdown pages pair with Blade layouts, and its deployment guidance explains how to publish the static files Jigsaw outputs. Jigsaw fits contributors who prefer Laravel’s ecosystem, though those details do not mean it takes less setup than other builders.
Starlight ships with features such as search and internationalization, according to its official overview. Your contributors may have fewer features to wire up themselves, but they still need to work with Astro and JavaScript. VitePress also centers on Markdown. Its overview describes a theme built for documentation sites along with support for Vue components inside Markdown.
Docusaurus supports documentation versioning and internationalization. Its versioning guidance also spells out the extra build and maintenance work that comes with multiple versions. Maintain separate versions when package users need release-specific instructions. If they do not, keep one current set of docs and link to your release notes.
Material for MkDocs includes built-in search, as covered in its search documentation. Its end-of-life announcement sets May 5, 2027 as the final date and names Zensical as its successor. Existing sites will keep working past that date, but if you are starting a new site, factor in the end date and check whether Zensical meets your needs.
Your builder generates the site, and your hosting setup serves those files to readers. Jigsaw and MkDocs output static files that you can deploy separately from your Laravel application. You can take that route when your docs are public and do not need Laravel’s authentication or middleware.
Some documentation needs application-controlled access. Scribe, for example, lets you generate static output or serve the docs through Laravel. Its setup documentation explains that Laravel applies middleware and authentication to the served option, while static files bypass Laravel altogether. Pick how you deploy based on who needs access and what access controls you have to enforce.
Read the Docs is a hosting service that works alongside a builder. It supports several documentation tools and provides managed builds and previews, as outlined in its product features. Check whether its hosted workflow fits how your contributors review and publish changes.
Before you spend time on heavy customization or multiple documentation versions, publish the essentials: installation instructions, a first working example, configuration details, and common use cases, along with troubleshooting advice and upgrade notes. If your package has many features, organize pages around what users are trying to do; structuring documentation for multi-feature packages covers one way to do that. You can also keep your instructions in sync with code changes by reviewing when to update package documentation.
Test how contributors preview and publish pages, in addition to testing the initial setup. Ask a contributor to make a small edit, preview it locally, and publish it through your planned review flow. If they have to learn an unfamiliar runtime or troubleshoot deployment details to fix a single line of text, pick a builder that better fits the people who will maintain the docs.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com