Blog

Docker Beautifiers + PHP Storm + Legacy code

I got tasked with updating a pretty old Joomla project, with the main job being to change the template.
The biggest challenge was the messy code, so I thought about installing php-cs-fixer.
Unfortunately, rebuilding the container is quite a time-consuming process.
I found ready-made containers online at https://hub.docker.com/r/unibeautify/php-cs-fixer/ 
After pulling with $docker pull unibeautify/php-cs-fixer,
the standard version involves running docker run from the console, but to put it mildly, that’s a hassle.

php-storm-tools.jpg 79.79 KB
run -i -v $ProjectFileDir$:/code -w /code unibeautify/php-cs-fixer fix $FileRelativePath$
Coming to our rescue is External Tool z PHP Storm
Now, after selecting a file or directory in the project tree, go to External Tools (Alt+T) > unibeautify/php-cs-fixer, and you can quickly improve the readability of legacy code.
I wouldn’t apply this tool to the entire project right away, but only to the elements you plan to modify—it’ll be easier to figure out what broke if something goes wrong.