PHP 8.6 is out. DressCode rewrites your code for it. Upgrading to a newer PHP →

Getting Started with DressCode

Get DressCode up and running in under a minute and test it on your codebase without modifying a single file. You will immediately see where your code deviates from a coding standard such as PER Coding Style 3.1 or Nette, what automated fixes would look like, and how modernizing to a newer PHP version would improve your code. DressCode formats your code and upgrades it to newer PHP and library APIs, all in a single run.

Installation

DressCode is a standalone tool, not a library, so you can install it completely outside the project it inspects. The quickest and easiest way is a global installation via Composer:

composer global require dresscode/dresscode

Make sure Composer's global bin directory is in your system PATH, and you can run dresscode from anywhere.

For continuous integration (CI) environments where you want the tool's version strictly locked, install it into a dedicated standalone directory:

composer create-project dresscode/dresscode temp/dresscode
temp/dresscode/bin/dresscode check

Alternatively, you can install DressCode directly into your project as a development dependency (composer require --dev dresscode/dresscode) and run it from vendor/bin/dresscode. Choose this approach whenever your project already uses PHPStan: DressCode queries PHPStan directly for type information, allowing it to reliably rewrite deprecated library APIs based on what a variable actually is (see Types from PHPStan). Keep in mind that DressCode itself requires PHP 8.4 to 8.6, meaning your project environment must run on one of these versions, even if the codebase itself targets an older PHP. DressCode's dependencies (among them nette/utils 4.1) must also get along with those of your project; for an older application that cannot meet this, install DressCode and PHPStan globally, as Upgrading Code describes.

Here is the most common point of confusion: the PHP version running DressCode and the target PHP version of your project are two entirely independent things. When DressCode runs globally or outside your project, it can run on PHP 8.5 while inspecting code written for PHP 8.1. It reads your project's target version directly from require.php in composer.json and respects it strictly, so it will never inject syntax that your target PHP cannot compile. All versions from PHP 8.0 upward are supported; older PHP versions are not supported and DressCode will warn you if you attempt to target them.

DressCode is built with minimal dependencies: the parser and the lossless syntax tree it builds upon are packaged into a standalone library, PhpSyntax, with zero external dependencies. On top of that, it relies only on four lightweight Nette packages, the PHPStan phpDoc parser, and Composer's version comparator. No framework.

What Do You Want to Do?

DressCode handles several distinct tasks, and each has its own dedicated guide. Choose the path that matches what you are working on right now:

  • Enforce a coding standard for an existing project: Format Your Code Step by Step takes you from the initial dresscode init all the way to a standard enforced automatically in CI.
  • Upgrade to a newer PHP version: Upgrading to a Newer PHP shows how to modernize code written for PHP 8.0 or newer to leverage features from subsequent releases up to PHP 8.6.
  • Update your libraries: Upgrading Code shows how to rewrite your code to the new API of your libraries: with a single command once you have raised the versions, or with a plan step by step that includes Composer and your tests. DressCode includes detailed upgrade data for Nette, Symfony, Laravel, and Dibi and Texy.
  • Switch from another tool: Switch to DressCode Step by Step guides you through converting existing configurations from PHP CS Fixer, PHP_CodeSniffer, or Laravel Pint.

If you'd rather try the tool first, read on. In the next few sections, you will run three commands on your codebase, and none of them will modify a single byte.

Check Your PHP Code Without Changing It

DressCode has no style of its own, which is why it intentionally refuses to run without a configuration. If it quietly defaulted to an arbitrary standard, running fix on an existing codebase with a different style would touch nearly every line. To try it, specify a standard using --use and supply the directories to check:

dresscode check src tests --use perCs

The terminal output looks like this:

DRESS|CODE 1.3.0
Config     none, using perCs
Target     PHP 8.2 from `composer.json`
Checking   214 files in /var/www/shop

src/Cart.php
  error   9:61  Expected a line break before the opening brace.         braces.position.function
  error  10:17  The array must be written `[…]` instead of `array(…)`.  literals.arraySyntax.array
  error  11:12  Expected no whitespace after the opening parenthesis.   spacing.padding.controlStructure
  error  11:20  Expected at least one space before the `==` operator.   spacing.binaryOperator
...

FOUND  36 violations, a fix leaves 1 in 12 of 214 files

Every finding tells you exactly where the violation occurred (line and column), what is wrong (a clear sentence describing the expected state), and which configuration decision was violated. The path on the right (e.g. braces.position.function) is the configuration key, which you can interact with directly: inspect its documentation and allowed values (dresscode explain braces.position.function), assign it a different value, look it up in the rules catalogue, or suppress it locally.

The header at the top clears up the two questions that cause the most confusion: what configuration and presets are being used, and which target PHP version applies. The summary at the bottom tells you exactly how many violations would remain after running an automated fix.

Every finding is reported as a full, self-contained sentence tied to a specific location. Whenever DressCode measures something, it reports both what it expected and what it found (Expected the statement indented by 12 spaces, 10 spaces found.).

Findings are not limited to how the code looks. DressCode also reports places that are most likely a mistake, and a fix that could change how the program behaves, a so-called risky fix, waits for your permission. The home page shows what such findings look like.

The exit code is 0 when the codebase is clean and 1 when violations are found, making the same command ready to run in continuous integration. A complete breakdown of all five exit codes is available in the command line reference.

See the Fix Before It Happens

Add the --diff option, and the check will display a unified diff of the changes fix would make directly under each file's findings:

dresscode check src tests --use perCs --diff
--- src/Cart.php
+++ src/Cart.php
@@ -6,9 +6,10 @@

 class Cart
 {
-    public function add(Product $product, int $count): void {
-        $line = array($product, $count);
-        if ( $count== 0) {
+    public function add(Product $product, int $count): void
+    {
+        $line = [$product, $count];
+        if ($count == 0) {
             return;
         }
         $this->lines[] = $line;

Nothing is written to disk. Review the diff just as you would review a pull request: if it adjusts things your team readily agrees on, the standard is close to your current habits. If it rewrites half of every file, your project clearly follows different conventions. You can immediately preview an alternative standard by changing a single word: --use psr12, --use nette, --use symfony, or --use laravel.

Preview an Upgrade to a Newer PHP

DressCode doesn't just format code, it also modernizes it for newer PHP versions. That is the job of the modernizations set. You can test it on its own without any formatting standard, so the diff isolates the modernizations:

dresscode check src --use modernizations --diff
return $article === null ? null : $article->getAuthor();
return $article?->getAuthor();

The set inspects your target PHP version in composer.json (require.php) and proposes only constructs that your target environment can safely execute. Bump that version, rerun the command, and you will instantly see what modern language features your code can take advantage of. This works all the way from PHP 8.0 up to PHP 8.6, which has not even been released yet. See Upgrading to a Newer PHP for what gets rewritten and a practical walkthrough.

When You Are Ready to Write

The command that writes changes to disk is fix, and like check, it will not start without a configuration. The --use perCs option from your dry run wasn't saved anywhere, so running a bare dresscode fix will exit with code 3:

Error: No `dresscode.neon` or `dresscode.php` found in `/var/www/shop` or above it, so there is no dress code to check against. Run `dresscode init` to have one made to measure from the code, or name a standard with `--use`.

You could repeat --use perCs to force DressCode to write everything shown in the diff. In an existing project with established conventions, however, that results in a massive, unreviewable pull request. A far better first step is dresscode init: it analyzes your existing code, picks the closest matching standard, records your project's actual deviations in dresscode.neon, and limits the initial fix to a small, safe set of files. Format Your Code Step by Step guides you through this process, from initial measurement to automated CI enforcement.

Only one command writes changes to disk without a configuration file: dresscode upgrade today. Following a library update, it rewrites your code to the new API, and it can do so because it leaves your formatting completely untouched (see Upgrading Code).

Where to Go Next

Show on GitHub · Report a problem with this page on GitHub · Nov 7, 2026