Sublime Forum

Sublime text 3 php code completion problem

#1

Hi, I just recently switch from notepad++ to sublime text 3. I love everything of sublime except the code suggest does not work well with php. Some simple functions works well like in_array(needle, haystack), similar_text(first, second). Nice snipped ! But lots of other are just missing for ex: when typing “mysqli_stmt”, I expect that sublime will provide me with mysqli_stmt_bind_param, mysqli_stmt_exercuse, ect. I think the function is recognized (because it turned blue), but somehow it does not show in the suggestion window. Do I need to install any extra packages for this to work ? Thanks

1 Like

#2

This is just because the functions you want aren’t included in the PHP.sublime-completions file.

To see a list of all of the PHP auto completions that are available just open the “/Packages/PHP.sublime-package” file in the Sublime Text 3 install directory by using something like 7zip or WinRAR or whatever you want.
Then open the “PHP.sublime-completions” file.

To add additional completions open the “/Data/Packages/User” directory (you can easily get to it by using ctrl + shift + p in Sublime and typing “browse”, then selecting the “Browse Packages” option).

Once you are in this directory you can create your own PHP.sublime-completions file (really you can name it anything you want).
Once created you can put whatever completions you want in there.

For example to start with you can paste in:

{
	"scope": "source.php - variable.other.php",

	"completions":
	
		"php",

		{ "trigger": "mysqli_stmt_bind_param", "contents": "mysqli_stmt_bind_param(${1:stmt}, ${2:types}, ${3:var_1})" },
		{ "trigger": "mysqli_stmt_execute", "contents": "mysqli_stmt_execute(${1:stmt})" }
	]
}

As soon as you save the file you should see “mysqli_stmt_bind_param” and “mysqli_stmt_execute” in the auto-completions popup menu.

1 Like

#3

Thanks a lots. I thought sublime gonna provide me full list of php function. I guess I have to install extra package (like code intel) for better code completion.

1 Like

#4

look for andyphp package…it provides a complete sublime completions file for php!!!

1 Like

#5

Thanks Fed003, Andyphp worked for me.

1 Like