Autocompletion for custom PHP classes in Sublime Text 2/3

3

How can I get autocomplete in Sublime Text 2 (or 3) to work with built-in and custom PHP functions, methods and classes?

In Atom I've got it working with built-in functions, like this:

enter image description here

In Sublime it lists built-in functions and some custom classes (after awhile) but without any arguments. Nothing else works.

Packages I've tried:

Oskar Persson

Posted 2015-08-17T15:31:57.487

Reputation: 898

2What plugin is that for Atom? – Edward – 2016-11-10T23:02:06.830

Answers

6

Highly recommend checking out Matt Stauffer's post on using Sublime Text 3 for PHP development.

https://mattstauffer.co/blog/sublime-text-3-for-php-developers

I am using SublimeCodeIntel. The trick for me was to ensure that the php interpreter was referenced correctly. Go to Sublime Text Preferences > Package Settings > SublimeCodeIntel > Settings - Default. Check that the language setting for php references the correct location for your php command, which you can find with which php in Terminal.

"codeintel_language_settings": {
        ...
        "PHP": {
            "php": "/usr/bin/php",
            "codeintel_scan_extra_dir": [],
            "codeintel_scan_files_in_project": true,
            "codeintel_max_recursive_dir_depth": 15,
            "codeintel_scan_exclude_dir":["/usr/bin/php/"]
        }
    }

If that block is wrong, copy to SublimCodeIntel user settings and modify as needed.

ToddSmithSalter

Posted 2015-08-17T15:31:57.487

Reputation: 253

Thanks, it seems like it suggests all available classes now. Though it still doesn't show the arguments for the constructor or the methods. – Oskar Persson – 2015-08-21T18:07:48.403

2

You can try PHPintel

Install PHPintel using Package Control
Create or open a project with PHP files
Run the command PHPIntel: Scan Project command from the command palette

After the initial scan, PHP files will be automatically re-scanned whenever you save them.

https://github.com/jotson/SublimePHPIntel

Arif

Posted 2015-08-17T15:31:57.487

Reputation: 441

Sorry but that package didn't work for me and it also has the really annoying process of adding a '.phpintel' folder under each folder opened in the project. Finally, as I write this, that extension is dead (no update since may '16). – MrBuBBLs – 2017-02-19T22:43:36.770

0

I was looking for the same thing but never found it. I wrote my own that adds autocomplete for class methods for composer installed packages. It also adds inline documentation for php functions on hover. (you have to download the manual and untar/gzip it. Hope it helps.

https://github.com/desean1625/CompletePHP

FYI the first run takes some time to index if you have a bunch of packages installed.

desean

Posted 2015-08-17T15:31:57.487

Reputation: 1