This extension allows you to run Easy Coding Standard (ECS) directly from Visual Studio Code. You can also configure it as formatter for PHP files.
- Open the command palette (
F1). - Select
Extensions: Install Extension. - Search for "PHP ECS Formatter" and install the extension.
- Use
Alt+Shift+F(Windows/Linux) orOption+Shift+F(macOS) if you've set this extension as the default PHP formatter. - Command Palette:
- Press
F1->php-ecs-formatter: fix this fileto format the currently open PHP file. - Press
F1->php-ecs-formatter: diffto compare the original and formatted versions of the currently open PHP file in a diff view.
- Press
- Context Menu:
- Right-click in the editor and choose "Format Document", "Format Selection", or "Format Document With" to explicitly select a formatter.
- Right-click a PHP file in the explorer and select
php-ecs-formatter: fixorphp-ecs-formatter: diff.
{ "php-ecs-formatter.executablePath": "./vendor/bin/ecs", // Can be a relative or absolute path "php-ecs-formatter.configPath": "./ecs.php", // Can be a relative or absolute path "php-ecs-formatter.onsave": false, }
Make sure ECS is installed in your project and accessible through the specified path in the configuration. For example, you can install ECS by running:
composer require symplify/easy-coding-standard --dev