PHP intelephense lsp setting not working! #23788
Replies: 25 comments 1 reply
-
I would love good PHP support in Zed. People don't realise how much PHP is used. |
Beta Was this translation helpful? Give feedback.
-
I need support for PHP in Zed |
Beta Was this translation helpful? Give feedback.
-
Does anyone know zed supports intelephense premium ? |
Beta Was this translation helpful? Give feedback.
-
This is important for me, too. Is it a bug, or are we supposed to set the configuration in some other way? |
Beta Was this translation helpful? Give feedback.
-
Premium should work, although not tested by myself: #6965 |
Beta Was this translation helpful? Give feedback.
-
I have a similar issue,
|
Beta Was this translation helpful? Give feedback.
-
braces format is also not being respected |
Beta Was this translation helpful? Give feedback.
-
Has anyone gotten Wordpress (and WooCommerce / ACF) stubs working in Zed? |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
This is a horrible kludge, but I got intelephense to respect the First I opened the zed log (
That file looked like this:
I added a couple paths to
…then restarted zed and opened some php files with a bunch of wordpress function calls and no error messages from intelephense. Go to definition does not work, but mousing over wp function calls does show me the function’s template. obviously there is some kind of disconnect between defining |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Could you please give a more detailed step-by-step explanation of what you had to do? I've forked Zed, installed Rust and Xcode (per these instructions), modified the files as in your commit, ran |
Beta Was this translation helpful? Give feedback.
-
@federicoangelli Yeah, no problem. Basically, part of the release process, I assume is to build the extensions into a WASM plugin, and those plugins are downloaded from some plugin/release server. I think if you run Zed and install the PHP extension, you should have a Now, the tool that's actually used to build the extension (which was somewhat hard to figure out), is in You should then edit the manifest.json file to have some version greater than Then, you move your built extension into the Do note that I did all this in Linux, and the case might be different for Mac, although the biggest difference might be where the extensions are stored. |
Beta Was this translation helpful? Give feedback.
-
@plugd-in You're right, I've managed to make it work following your steps. On macos, the path to where extensions are installed is |
Beta Was this translation helpful? Give feedback.
-
@osiewicz Any chance of getting @plugd-in’s patch incorporated into the official PHP extension so I can avoid setting up a dev environment to be able to compile Zed? 😄 |
Beta Was this translation helpful? Give feedback.
-
v0.1.2 of the PHP extension now has support for reading the LSP settings from the Zed settings: Here's how the settings should be structured in your {
"lsp": {
"intelephense": {
"settings": {
"stubs": ["foo", "bar"],
"files": {
"maxSize": 1000001
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
this one is working for me:
|
Beta Was this translation helpful? Give feedback.
-
I have opened an issue: |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, this does not work for me. I just want to remove the directories /old/ and _old from code completion. But the setting is simply ignored and classes from _old are displayed. Also includePaths do not work. Too bad, I would have loved to switch to the zed IDE for PHP development. |
Beta Was this translation helpful? Give feedback.
-
For those who need to set up intelephense for Drupal, this is what works for me:
|
Beta Was this translation helpful? Give feedback.
-
This ended up being what I needed, thanks for sharing. |
Beta Was this translation helpful? Give feedback.
-
I'm going to move this to the Zed Language support discussions. If folks have suggestions for incorporate additional configuration suggestions to always happy to PRs to docs/languages/php.md. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Has anyone managed to make PHP_CodeSniffer (with a .phpcs.xml) work with Zed? Using Intelephense and phpactor at the same time is impossible and I prefer Intelephense. Phpactor simply consumes 100% of my Mac M1 Pro every time I activate it and apparently there's some incompatibility with Intelephense. I tried using an external formatter but without success.
"formatter": {
"external": {
"command": "vendor/bin/phpcbf",
"arguments": [
"-s",
"--standard=.phpcs.xml",
"{buffer_path}"
]
}
} Without support for PHPCS, Zed becomes completely useless for those who work with PHP. Which is a shame. |
Beta Was this translation helpful? Give feedback.
-
I don't use php-cs-fixer, I use phpcs/phpcbf, what I did was something similar but I created a shell script for that, since Zed does not allow saving a file in the formatter; the formatter needs to return to the buffer. So I created an alias for the bash script named #!/bin/bash
set -e
# Capture standard input
INPUT_CODE=$(cat)
if [ -z "$INPUT_CODE" ]; then
echo "Error: No code provided via standard input." >&2
exit 1
fi
# Check if PHPCBF is installed
PHPCBF_PATH=$(which phpcbf 2>/dev/null)
if [ ! -f "$PHPCBF_PATH" ]; then
echo "Error: phpcbf not found. Check installation." >&2
exit 1
fi
# Check if phpcs configuration file exists
PHPCS_CONFIG="./.phpcs.xml"
if [ ! -f "$PHPCS_CONFIG" ]; then
echo "Error: Configuration file $PHPCS_CONFIG not found." >&2
exit 1
fi
# Create temporary directory securely
TEMP_DIR=$(mktemp -d -t phpcbf-zed-XXXXXX) || { echo "Error: Failed to create temporary directory." >&2; exit 1; }
TEMP_FILE="$TEMP_DIR/file_$(date +%s)_$RANDOM.php"
# Cleanup function to ensure temporary files are removed
cleanup() {
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT
# Save code to a temporary file
echo "$INPUT_CODE" > "$TEMP_FILE" || { echo "Error: Failed to write to temporary file." >&2; exit 1; }
# Execute phpcbf with error handling
if ! phpcbf --standard="$PHPCS_CONFIG" "$TEMP_FILE" > /dev/null 2>&1; then
# phpcbf returns non-zero exit status if it makes changes,
# so we don't treat this as an error, just log it
echo "Warning: phpcbf made changes to the code or encountered issues." >&2
fi
# Return the formatted code
if [ -f "$TEMP_FILE" ]; then
cat "$TEMP_FILE"
else
echo "Error: Temporary file was not found after processing." >&2
exit 1
fi Zed Settings "PHP": {
"language_servers": ["intelephense", "!phpactor"],
"format_on_save": "on",
"formatter": {
"external": {
"command": "phpcbf-zed"
}
}
} Unfortunately, Zed does not have a lint for phpcs. |
Beta Was this translation helpful? Give feedback.
-
According to intelephense docs, i want to set
wordpress
stub insideintelephense.stubs
So, i just configure the editor based on zed docs :
But didn't working !!
Thanks
Beta Was this translation helpful? Give feedback.
All reactions