Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

How to run php-cs-fixer on PHP 8.4

Not officially supported yet

Joel Clermont
Joel Clermont
2025-06-11

From our daily Laravel tips email. Get the next one in your inbox.

We like to use PHP CS Fixer on our projects to enforce coding standards. We even have our own custom config that we publish and use across all our projects.

Interestingly, despite PHP 8.4 being released in November 2024 (over 6 months ago as of this tip), PHP CS Fixer does not yet officially support it.

What are we to do? Are we stuck on PHP 8.3 for now?

Thankfully, no. You can prefix your command with an environment value to force it to run on PHP 8.4.

It looks like this: PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer check

Is this risky? What could break?

Well, anything unsupported could break or have unexpected behavior, so this does involve a measure of risk.

In our case, we never have a CI pipeline or tool automatically fix and commit changes. It's always done by a developer in a local git feature branch.

So it's up to the developer to make sure nothing unexpected happened.

I've tried this approach across a handful of fairly large projects while upgrading to PHP 8.4, and haven't seen any issues yet, so I wanted to share this solution.

You can track the official support for PHP 8.4 in this GitHub milestone to know when this workaround is no longer needed.

Here to help,

Joel

P.S. Did the thought of running PHP 8.4 in your project make you laugh since you're still stuck on PHP 5? We can help you upgrade.

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.