Skip to content
Laravel Fmt is in public beta. Found a bug? Open an issue →
v0.8.0Changelog →

A modern code formatter for Laravel, written in Go.

Formats PHP, Blade, and Livewire 4 with Tailwind class sorting. No Node. No Prettier plugin. Just PHP 8.3+.

composer require jacobjoergensen/laravel-fmt --dev
After Laravel Fmt:
<?php
namespace App\Http\Controllers;
use App\Models\Post;
use App\Models\User;
class PostController
{
public function index(User $user)
{
$posts = Post::query()
->whereBelongsTo($user)
->latest('published_at')->get();
return $posts;
}
}
Before Laravel Fmt:
<?php
namespace App\Http\Controllers;
use App\Models\User;
use App\Models\Post;
class PostController {
public function index(User $user){
$posts=Post::query()
->whereBelongsTo($user)
->latest('published_at')->get();
return $posts;
}
}

What it formats

PHP

*.php

Sorts imports, splits grouped ones, and drops a trailing ?>.

Blade

*.blade.php

Echoes, directives, and @php blocks go through the PHP formatter.

Livewire 4

⚡*.blade.php

Single-file pages and components, markup and class together.

HTML

*.html

Tailwind classes are sorted, and Alpine expressions get consistent spacing.

CSS

*.css

The @theme block also feeds Tailwind class sorting.

Alpine.js

x-data@*

Expressions in x-data, x-on, and @ attributes get consistent spacing.

Markdown

*.md

Line wrapping follows markdown.proseWrap.

JSON

*.json*.jsonc

Indented 2 spaces, or 4 in composer.json, unless indentWidth is set.

YAML

*.yml*.yaml

Always indented with spaces.

XML

*.xml

A trailing .dist is ignored, so phpunit.xml.dist formats as XML.

Other files are skipped. Full list →

Features

CONFIG

Reads your config

Settings from your Pint, PHP-CS-Fixer, Mago, EditorConfig, and Prettier files are adopted, so there is nothing to restate. Run init when you want a file of your own.

TAILWIND

Blade-aware sorting

In bg-{{ $color }}-500, bg- is only a class once Blade fills the hole. Laravel Fmt pins it and sorts around it.

THEME

Reads your theme

The @theme block in your stylesheet is loaded before anything is sorted, so bg-brand lands with the built-in colors instead of first.

ALPINE

Verified rewrites

Alpine attributes get canonical spacing. The result is read back token by token, and your original is kept if anything moved.

LSP

Language Server

laravel-fmt lsp speaks LSP over stdio for format on save and format selection. Editors that only pipe a buffer use --stdin-filepath.

PARALLEL

Parallel, in order

Every core takes a share of the files. Results come back in the order you passed them, so --check prints the same lines every run.