|
The latest version of Phoenix is reporting a whole load of Undefined function errors when these are all WordPress functions (eg: get_header). Is there a way to disable error checking for external function? |
Replies: 4 comments 1 reply
|
Hi @fisicx, Thanks for reporting this issue. Yes, there's a way to do this, see below: (Detailed Docs link...) WordPress functions like The proper fix is to install the WordPress stubs so the editor actually knows what these functions are, you get real hover docs/autocomplete for them too, not just quiet: Open View > Terminal in Phoenix Code (gives you a terminal already sitting in your project folder, same on Windows/Mac/Linux) and run: composer require --dev php-stubs/wordpress-stubs(If it says Then create a file named {
"environment": {
"includePaths": ["vendor/php-stubs/wordpress-stubs"]
}
}Restart Phoenix Code (or switch between projects) afterwards so it picks up the config file. If you'd rather not deal with Composer, you can just turn the check off instead. Same file, but with this in it: {
"diagnostics": {
"undefinedFunctions": false
}
}Note that this only silences the error, the editor still won't know what these functions are, so you won't get hover docs/autocomplete for them. Also worth committing |
|
Please see if this works, if so we will add better auto detection and support of frameworks based on this. |
|
The github code doesn't work. Keep getting a command not found message no matter what I try. For example: bash: php: command not found I suspect because I don't have php installed locally. The problem has only arisen in the latest update. Yesterday it was all good and I was only seeing coding errors. Can you add in an option to ignore external functions? |
|
OK that works. I'll investigate installing php locally but I push everything to a dev server so really don't need to run anything locally. |
Hi @fisicx, Thanks for reporting this issue.
Yes, there's a way to do this, see below: (Detailed Docs link...)
WordPress functions like
get_header()aren't part of PHP itself, they're defined by WordPress core, which the editor can't see if you're just working inside a theme or plugin folder. So it flags them as undefined even though your code is fine.The proper fix is to install the WordPress stubs so the editor actually knows what these functions are, you get real hover docs/autocomplete for them too, not just quiet:
Open View > Terminal in Phoenix Code (gives you a terminal already sitting in your project folder, same on Windows/Mac/Linux) and run: