How to use phpfmt in sublime text 3

Questions : Sublime Text 3 php-fmt wont work

2022-09-25T08:02:11+00:00 2022-09-25T08:02:11+00:00

736

I'm trying to use php-fmt plugin for ST3, I anycodings_sublimetext3 installed it, but when i use the keys it anycodings_sublimetext3 doesn't do anything. I think I setup anycodings_sublimetext3 everything correctly but the php file anycodings_sublimetext3 doesn't get any format. I can use PHP on anycodings_sublimetext3 command line... I followed the setup. I'm on anycodings_sublimetext3 OSX, using MAMP php 5.5.10

also if i use the command 'analyze' i get anycodings_sublimetext3 the message

Autocomplete and autoimport need building a database of terms.
Please, fill in below with the proper location for this database.
Keep in mind that the best location is always the root of the project, therefore limiting the size and ensuring speed.

If you have any idea why it doesn't work anycodings_sublimetext3 please help or suggest an alternative to anycodings_sublimetext3 format PHP code Thanks!

Total Answers 2

27

Answers 1 : of Sublime Text 3 php-fmt wont work

On the the menu go to Preferences > anycodings_sublimetext3 Package Settings > phpfmt > anycodings_sublimetext3 Settings - User

Edit the file that will open in result anycodings_sublimetext3 of the previous action.

Specify the "php_bin" according to your anycodings_sublimetext3 php binary location,

It should contain something like this:

{
    "enable_auto_align": false,
    "indent_with_space": true,
    "passes":
    [
    ],
    "php_bin": "/Applications/MAMP/bin/php/php5.5.10/bin/php",
    "psr1": true,
    "psr2": true,
    "version": 2

}

0

2022-09-25T08:02:11+00:00 2022-09-25T08:02:11+00:00Answer Link

mRahman

1

Answers 2 : of Sublime Text 3 php-fmt wont work

This answer is for newer version.

SublimeText 3 and PHPfmt 4

On the the menu go to Preferences > anycodings_sublimetext3 Package Settings > phpfmt > anycodings_sublimetext3 Settings - User and add below code, anycodings_sublimetext3 please make sure PHP >= 5.6 is anycodings_sublimetext3 installed on path C:/php/php.exe or you anycodings_sublimetext3 can replace with your PHP.exe path anycodings_sublimetext3 below:

{
 "version": 4,
 "php_bin":"C:/php/php.exe",
 "format_on_save":true,
}

0

2022-09-25T08:02:11+00:00 2022-09-25T08:02:11+00:00Answer Link

raja

Top

  • © 2022 ANYCODINGS.COM - All Rights Reserved.
  • About Us
  • Contact Us
  • DMCA
  • Privacy Policy
  • Disclaimer
  • Terms & Conditions

How to use phpfmt in sublime text 3

Sublime Text 3 has awesome packages for all kinds all things and in this blog post I will write about packages that make me happy when using for web development. So let's start!

Package Control

First things first, We need to install Package Control to install other packages. To install package control we open Command Palette, to open it go to Tools->Command Palette or with shortcut Shift+Ctrl+P on Linux.

Here is the picture:

How to use phpfmt in sublime text 3

now we can install other packages with Package Control. You can search and install other packages by name via opening command palette and typing Install Package then you just type the packages name you want to install. Also we can browse packages on https://packagecontrol.io  and you can read documentation, usage and configuration of packages.

PHPFMT

The first package I install after Package Control is phpfmt. This packages is a must have for php developers. With PHPFMT you can format your code when you save file, to install packages using package control press Shift+Ctrl+P to open command pallette and type 'install' then type the package name you can to install in our case this is phpfmt.

How to use phpfmt in sublime text 3

Before we can use this package we must define path to php binary file. Open config settings Preferences->Package Settings->phpfmt->Settings - User. Attention! never modify Settin_gs - Default file as the changes will be lost once Sublime updated.

How to use phpfmt in sublime text 3

   Specify php_bin to location of php binary and don't forget to set       

   format_on_save to true and then you can forget about all this as it

   will format your php code automatically.

How to use phpfmt in sublime text 3

SublimeLinter

SublimeLinter PHP (and its required dependency, SublimeLinter) rely on PHP's built-in linter. This is a simpler version that only runs the linter, nothing else. This check errors on your php code. Install it just like you installed phpfmt.

GitGutter

GitGutter shows you git diff on Sublime. modified or deleted, updated?

How to use phpfmt in sublime text 3

SideBarEnhancements

SideBarEnhancements as the name suggests extends sublime's sidebar.

How to use phpfmt in sublime text 3

SFTP

Great package enabling very comfortable use of SFTP, FTP and FTPS. It supports remote folders browsing, editing and synchronization between local and remote files. Also regular upload, download, save or file open.

jsPrettier

This package is not for php but it is my go to package when working with javascript files. This package like phpfmt formats javascript code. Before using this package we must install prettier depency install with this command

npm install -g prettier

Then install jsPrettier package and open settings file like we opened on phpfmt. As an example config:

{
	"debug": false,
	"prettier_cli_path": "/home/tasqyn/.asdf/installs/nodejs/9.2.0/.npm/bin/prettier",
	"node_path": "/home/tasqyn/.asdf/shims/node",
	"auto_format_on_save": true,
	"auto_format_on_save_excludes": ["*/node_modules/*"],
	"allow_inline_formatting": true,
	"custom_file_extensions": [],
	"max_file_size_limit": -1,
	"additional_cli_args": {},
	"prettier_options": {
		"printWidth": 100,
		"singleQuote": false,
		"trailingComma": "none",
		"bracketSpacing": true,
		"jsxBracketSameLine": false,
		"parser": "babylon",
		"semi": true,
		"requirePragma": false,
		"proseWrap": true
	}
}

prettier_cli_path - path to prettier.

node_path - path to node

You can change settings accordingly to your needs.

How to use phpfmt in sublime text 3

Conclusion

These are the packages I use all the time. Of course there are many packages for Sublime Text 3, You can browse them on packagecontrol.io and choose your favorites.

This is my first blog post like ever so there be many mistakes feel free to point it out.

Thank you for reading!

How can I beautify PHP code in Sublime Text 3?

Usage. ctrl + shift + P and type Tidy PHP , or you can use the ctrl + alt + T keybinding.

How to install php Package in Sublime Text 3?

Install SublimeLinter-php on Windows.
Unzip the files into C:/PHP/.
Open Sublime..
Press CTRL+SHIFT+P..
Enter Install Package and choose Package Control: Install Package..
Enter SublimeLinter and click on enter to install..
Do the same in step 5 and 6 for the package SublimerLinter-PHP..