Skip to content
Laravel Fmt is in public beta. Found a bug? Open an issue →
Usage  /  Editors
Edit this page

Editors

Format on save with the built-in language server, or by piping a buffer through stdin.

beta

Editor plugins for PhpStorm and VS Code are coming soon. Until then, use the language server below.

The language server

Terminal
vendor/bin/laravel-fmt lsp

It formats documents and selections over stdio, with the same config and ignored files as the CLI. A broken config shows up as a message in the editor.

Editor plugins can ask for a file’s endOfLine with a laravel-fmt/endOfLine request. A laravel-fmt/format request formats the text it is sent, or a range of it, and returns the edits and the file’s endOfLine.

Piping a buffer

Editors without LSP support can pipe the buffer through --stdin-filepath. The path picks the language.

Terminal
vendor/bin/laravel-fmt --stdin-filepath app/Models/User.php < input.php

If the code does not parse, nothing is written and your buffer is kept. To format a selection, add --range-start and --range-end.