Main menu
WalkswithMePHPSublime Text Configuration for PHP

Sublime Text Configuration for PHP

Sublime Text is a powerful text editor , its not just a text editor compare to other text editor the plug-ins of sublime text enables it to a complete IDE options. Here I will tell you the basic configuration required for PHP development using sublime text.

Sublime Text Configuration for PHP have the following main plug-ins.

  • PHPfmt
  • Sublime linter
  • Sublime Linter – PHP
  • Bracket highlighter
  • HTML beautify.
  • Git Gutter
  • Alignment

There are many other useful plug-ins available for Sublime text. First of all install the Sublime text latest version on your system based on your OS Win/Linux. Once you installed the Sublime Text good to go with package Controller. You have to run the Python code provided by the package controller io. Based on Sublime text version choose the script code. Open your console with Ctrl+` Paste the code and press enter. once it render you may need to restart the Sublime Text, It will install the required dependency as well.

Now you will be able to install other plug-ins packages via pressing Ctrl + Shift + P . then type ” install ” it will load all the repository for you the just type the above list of plug-ins name one by one .

Once you install all the required list now you can configure each of the plug-ins with you customization.

PHPfmt Configuration

Open the Preference menu of sublime text -> Package Settings -> PHPfmt-> user Settings. Paster the following codes.


{
"disable_auto_align": true,
"format_on_save": false,
"indent_with_space": false,
"passes":
[
],
"php_bin": "/usr/bin/php",
"psr1": true,
"psr2": true,
"version": 3
}

make sure your PHP installation path is correct. Now you can set the short for formatting the phpfmt output Preference -> Key Binding – User  paster the following codes.


[
{
"keys":    ["alt+shift+c"],
"command": "fmt_now"
}
]

I set it to  alt+shift+c you can set it to your own key combination.

 Sublime linter

This is an awesome plug-in that helps to detect PHP syntax errors while you  coding.

Open Preference -> Package Settings -> Sublime Linter -> User Settings.


{
"user": {
"debug": true,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/User/SublimeLinter/Monokai Bright (SL).tmTheme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"php": {
"@disable": false,
"args": [],
"excludes": []
},
"phplint": {
"@disable": false,
"args": [],
"excludes": []
}
},
"mark_style": "outline",
"no_column_highlights_line": false,
"passive_warnings": false,
"paths": {
"linux": [],
"osx": [],
"windows": []
},
"python_paths": {
"linux": [
"/usr/bin/php"
],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": true,
"show_marks_in_minimap": true,
"syntax_map": {
"html (django)": "html",
"html (rails)": "html",
"html 5": "html",
"php": "html",
"python django": "python"
},
"warning_color": "DDB700",
"wrap_find": true
}
}

You can set the basic theme and spacing of tab index and all with following code. add the code inside your Preference -> User Settings


{
"auto_complete": true,
"auto_complete_delay": 0,
"bold_folder_labels": true,
"close_windows_when_empty": false,
"color_scheme": "Packages/User/SublimeLinter/Monokai Bright (SL).tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"find_selected_text": true,
"fold_buttons": true,
"folder_exclude_patterns":
[
".svn",
".hg",
"CVS",
"_build",
"dist",
"build",
"site",
"report",
"node_modules",
],
"font_face": "Ubuntu Mono",
"font_options":
[
"subpixel_antialias"
],
"font_size": 12,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}

Forced refresh of the Project folder can be set with short cut key combination add the following code inside your User key binding.


{ "keys": ["ctrl+f7"], "command": "refresh_folder_list" }

here also the make sure the php path is correct as well, I’m on Linux machine so settings are are according to that.

If you preferred more package for JS and CSS like Js beautify or Less and Sass support etc are also available in Sublime Text Package repo.

Hope this article will help you to set up the PHP coding standard with PSR-2 using Sublime Text .

 

3 thoughts on “Sublime Text Configuration for PHP

  1. oye.. Super .. i did searched on sublime phpfmt settings and i accidentally came on this.. before leaving the site, i went to bookmark this, and i just noticed that url walkswithme.net and remembered you Jobin.. LOL ..anyway helpful

Leave a Reply

Your email address will not be published. Required fields are marked *

 

FacebookTwitterGoogle+RSS