One of the things you’ll find annoying if you’re trying to adhere to the PSR standards is that it’s hard to notice things like extra spaces at the end of lines and that you don’t have a blank line at the end of your file. You can run something like phpcbf to fix the file before you commit (and that’s a perfect option which will discuss in another article) but it’s nice to have sublime clean up whenever possible before you save.
Install the Plug-in
Step one is to install the plug-in. You should already have Package Control installed from earlier so we’re going to use the nice process of:
- Type “Package Control: Install Package” (or you can copy and paste what I just typed)
- Type “EditorConfig”
- Press “Return”
Add a .editorconfig
To do this we’re going to create a new file named “.editorconfig” at the root of our project and paste in the following:
Now when we work on .php files the editor will automatically indent using 4 spaces (indent_style and indent_size), use Unix style end of lines (end_of_line), keep an empty line at the end of the file (insert_final_newline), save using utf-8 (charset), and remove any extra whitespace at the end of a line (trim_trailing_whitespace).
Generally, I try to stick to to these same standards for my JS and SASS files so normally I’ll do:
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows