Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC]: Better way to get WordPress intellisense #2

Open
swashata opened this issue Jul 4, 2018 · 13 comments
Open

[DOC]: Better way to get WordPress intellisense #2

swashata opened this issue Jul 4, 2018 · 13 comments

Comments

@swashata
Copy link

swashata commented Jul 4, 2018

Hi,

First of all thank you very much for this awesome package. Your package is one of many reasons why I moved from Sublimetext to VSCode (don't mean to start a war here though).

I have been fiddling around a bit, and have been trying various methods to add WordPress intellisense. My preference has always been to just add the plugin/theme directory to vscode workspace. But in order to get intellisense of WordPress core functions, I had to add WordPress source in the workspace too. Not a great fan of this.

Then I came across this and since I use composer anyway, getting intellisense was a breeze.

I would've wanted to contribute to some doc, but since I didn't find any, I am opening an issue explaining the method and I leave it upto you to do what-so-ever you wish.

These are just the steps one need to follow to get WP intellisense.

  1. First increase the default fileSize to 3MB or greater (VSCode > Preference > User Settings) "intelephense.file.maxSize": 3000000.
  2. Now if you are using composer then composer require --dev giacocorsiglia/wordpress-stubs.
  3. If you are not using composer then simply download wordpress-stubs.php and put it in your project directory (you probably don't want to track it with git).
  4. Now from vscode command palette simply do a Intelephense: Clear Cache and Reload.
  5. Also disable any WordPress core snippets extension you might have.

And from then on, it just works. Here's a video.

WP Intelephense

@bmewburn bmewburn transferred this issue from bmewburn/vscode-intelephense Feb 26, 2019
@michael-land
Copy link

set maxSize to 3200000 if giacocorsiglia/wordpress-stubs version is ^5.1

@szepeviktor
Copy link

Up-to-date WP stubs are available here: https://github.com/php-stubs/wordpress-stubs

@HowdyMcGee
Copy link

Is there a global way I can install this? I jump from WordPress project to project all day and installing this per project just doesn't seem feasible for me. Open to suggestions, otherwise I'll likely disable Intelephense entirely.

@vpjm
Copy link

vpjm commented Dec 4, 2019

I would also like to know if there is a global way to do this. Adding this to each project seems unnecessary. I don't like to have files that I don't need in my project directories. Is there any extension that can be installed to accomplish this?

@ntwb
Copy link

ntwb commented Dec 14, 2019

This was added in 1.3.3

See bmewburn/vscode-intelephense#833 (comment)

@nichols-green
Copy link

For those looking for an answer to this in 2021, simply install Intelephense, and in the settings, add Core and Wordpress to the Intelephense: Stubs section in preferences.
stubs
No need to add the stubs through composer or download.

@firecrauter
Copy link

Thanks nichols-green.
For those who don't know much about vscode, I'll save you the search:
image
image

@oliver-la
Copy link

oliver-la commented Aug 27, 2021

I'd like to add my 2 cents here. I wanted to set up vscode for WordPress development, and one of the first extensions I installed was PHP Intelephense. It proved to be ridiculously difficult to find Intelephense already ships with WordPress support and it has to explicitly be enabled. Only learned about this when digging through multiple GitHub issues.

A great first step would be to link to bmewburn/intelephense-docs in the main repo of the vscode extension. I looked everywhere for a link to the documentation.

Second, the documentation should include all optional features, with full descriptions. At least the premium features should be documented properly, there's no point in paying for features if you don't know how to use or enable them.

@DLX23
Copy link

DLX23 commented Mar 21, 2022

possible to integrate acf (advanced custom fields) too?

@ntwb
Copy link

ntwb commented Mar 22, 2022

possible to integrate acf (advanced custom fields) too?

Yes, ACF stubs seem available here, so install those with Composer and add it to the stubs list

https://github.com/php-stubs?type=source

@oliver-la
Copy link

oliver-la commented Mar 22, 2022

@ntwb I use this approach as well, and it works great! Wish there was a way to tell intelephense to search for globally installed stubs, so they don't have to be included in every project separately.

@szepeviktor
Copy link

szepeviktor commented Mar 22, 2022

they don't have to be included in every project

I make many errors in my code (which I write ~once a month).
Using three default checks makes me more confident.

  1. syntax errors
  2. coding style
  3. static analysis

I run my code after these do pass. (not before!)

@yousufislamme
Copy link

Thanks nichols-green. For those who don't know much about vscode, I'll save you the search: image image

Thanks a lot this is a very helpful trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests