This extension provides document formatting using PHP CS Fixer.
- Lint your PHP using PHP CS Fixer
- Including formatting on save
- Using the configuration file present in the project root
- Uses the PHP CS Fixer version present in
vendor
You must have PHP CS Fixer installed in you project (this extension looks for the binary at vendor/bin/php-cs-fixer
).
Rules are read from the standard configuration files; .php_cs
or .php_cs.dist
.
There are no specific configuration settings provided by this extension. Configuration is done through the .php_cs
file.
However, to configure this extension as the default formatter for PHP and to format on save, include this in your settings.json
:
"[php]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "jradtilbrook.php-cs-fixer",
},
- Press
F5
to open a new window with your extension loaded. - Run your command from the command palette by pressing (
Ctrl+Shift+P
orCmd+Shift+P
on Mac) and typingHello World
. - Set breakpoints in your code inside
src/extension.ts
to debug your extension. - Find output from your extension in the debug console.
- You can relaunch the extension from the debug toolbar after changing code in
src/extension.ts
. - You can also reload (
Ctrl+R
orCmd+R
on Mac) the VS Code window with your extension to load your changes.
- Open the debug viewlet (
Ctrl+Shift+D
orCmd+Shift+D
on Mac) and from the launch configuration dropdown pickExtension Tests
. - Press
F5
to run the tests in a new window with your extension loaded. - See the output of the test result in the debug console.
- Make changes to
src/test/suite/extension.test.ts
or create new test files inside thetest/suite
folder.- The provided test runner will only consider files matching the name pattern
**.test.ts
. - You can create folders inside the
test
folder to structure your tests any way you want.
- The provided test runner will only consider files matching the name pattern