Editors
Format on save with the built-in language server, or by piping a buffer through stdin.
Editor plugins for PhpStorm and VS Code are coming soon. Until then, use the language server below.
The language server
vendor/bin/laravel-fmt lspIt 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.
vendor/bin/laravel-fmt --stdin-filepath app/Models/User.php < input.phpIf the code does not parse, nothing is written and your buffer is kept. To format a selection, add --range-start and --range-end.