Đối với lampp 7.3.10 thì chúng ta vào theo cách sau (ok)
{
"version": 4,
"php_bin":"/opt/lampp/bin/php",
"indent_with_space": true,
//This can be enabled with the option “enable_auto_align”
"enable_auto_align": true,
"format_on_save":false,
"option": "value"
}
{
"version": 4,
"php_bin":"/opt/lampp/bin/php",
// Note the identation of 2 spaces.
"indent_with_space": 2,
"enable_auto_align": true,
"format_on_save":false,
"option": "value"
}
{
"version": 4,
//"psr1":true function add_count($slug) => function addcount($slug)
"psr1":false,
"psr2":true,
// "psr2":true function add_count($slug) {
// }
// Convert to
// function add_count($slug)
// {
// }
"php_bin":"/opt/lampp/bin/php",
"indent_with_space": 2,
"enable_auto_align": false,
"format_on_save":false,
"identation": 2,
"option": "value"
}
<?php
for ($i = 0; $i < 10; $i++) {
if ($i % 2 == 0) {
echo "Flipflop";
}
// Đây là khoản trống trông rất khó chịu
}
chuyển thành
<?php
for ($i = 0; $i < 10; $i++) {
if ($i % 2 == 0) {
echo "Flipflop";
}
}
Chú ý:
Tham số "StripSpaceWithinControlStructures",
{
// "autocomplete": true,
// "autoimport": true,
// "enable_auto_align": false,
"format_on_save": true,
// "ignore": "Parent",
"indent_with_space": 2,
"passes":
[
// "ReindentSwitchBlocks",
// "OrderAndRemoveUseClauses",
// "PSR2EmptyFunction",
"StripSpaceWithinControlStructures",
// "ShortArray",
// "SpaceBetweenMethods",
// "AutoSemicolon"
],
"php_bin": "/opt/lampp/bin/php",
"psr2": true,
"smart_linebreak_after_curly": true,
"version": 4,
"visibility_order": true,
"yoda": true
}
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.
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.