Configuring phpfmt for Sublime Text and PSR Coding Standards
- Use Homebrew to install PHP 5.5:
brew install php55
- Install the plugin through Package Manager:
- In Sublime Text press
ctrl+shift+P
- Choose
Package Control: Install Package
- Choose
phpfmt
- In Sublime Text press
- Update your preferences to adhere to PSR standards:
- Preferences > Package Settings > phpfmt > Settings - User
- Paste the code below and save
{
"psr1":false,
"psr2":true,
"php_bin":"/usr/local/bin/php",
"indent_with_space":true,
"format_on_save":true,
"disable_auto_align":true
}
This will auto-format your code to PSR standards every time you save a PHP file.
- If needed, run
which php
to update the location of your PHP binary. psr1
forces text after PHP open tags to a new line, meaning you can't neatly addecho
statements into your markup. Planning to create an issue and pull request. In the meantime, just set to false.