Skip to content

Commit 350567e

Browse files
committed
docs: php intelliphense config
1 parent 7686401 commit 350567e

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

docs/07-Code Intelligence/02-php.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,38 @@ To turn PHP code intelligence off, set the `codeIntelligence.php` [preference](/
2727

2828
The free version of Intelephense covers everything described above. If you own an [Intelephense premium license](https://intelephense.com), set the `php.licenseKey` [preference](/docs/editing-text#editing-preferences) to your license key, or to the path of your license file.
2929

30+
## Working With Frameworks (WordPress, Laravel, etc.)
31+
32+
PHP code intelligence only knows about the PHP files it can see. If your project is a WordPress theme or plugin (or any codebase that leans on functions/constants defined by a framework you don't have locally, like `get_header()`), those calls show up as **"Undefined function"** errors in the [Problems panel](/docs/Features/Problems%20Panel/ESLint) even though the code is correct.
33+
34+
Fix this by dropping an `intelephense.config.json` file in your project root, then restart Phoenix Code so PHP code intelligence picks it up.
35+
36+
**Recommended: point it at the framework's stub files** so the functions are actually recognized (you get real hover info and completions, not just silence):
37+
38+
```json
39+
{
40+
"environment": {
41+
"includePaths": ["vendor/php-stubs/wordpress-stubs"]
42+
}
43+
}
44+
```
45+
46+
Install the stubs with Composer first, e.g. `composer require --dev php-stubs/wordpress-stubs` for WordPress. Similar stub packages exist for WooCommerce, Laravel, and other frameworks.
47+
48+
> Composer puts the stubs inside your project (`vendor/…`), so the path above works as-is on Windows, macOS, and Linux. Pointing `includePaths` at your actual local WordPress install instead would work too, but the path is different for every setup (XAMPP, MAMP, Local, Docker, …) and you'd have to track it down yourself — the stub package sidesteps that entirely.
49+
50+
**Quicker: just turn the check off**, if you don't want to set up stubs:
51+
52+
```json
53+
{
54+
"diagnostics": {
55+
"undefinedFunctions": false
56+
}
57+
}
58+
```
59+
60+
> Commit `intelephense.config.json` to your repo so the whole team gets the same settings. See the [configuration reference](https://intelephense.com/docs) for the full list of `diagnostics` and `environment` options.
61+
3062
## Running PHP Pages
3163

3264
This page is about editing PHP. To preview PHP pages in the Live Preview, see [PHP Live Preview Setup](/docs/Features/Live%20Preview/php-live-preview).

0 commit comments

Comments
 (0)