VS Code unable to use PHP Intellsense - php

I want to use PHP IntelliSense while using WSL environment but VScode is unable to find PHP path. What I should do fix this? I searched for some info but I only see scripts but none worked for me.

Try bash -c "php". WSL exposes a bash.exe binary on Windows, and if everything is correct it will already be in the environment variables, just by invoking it as bash - At least here, where I am using WSL2 with Ubuntu 20.04.
You try also, wsl -- "php" or wsl --exec "php".
UPDATE: Forget what I said above !!
Use the Remote - WSL extension . I believe you're already using it.
Add the following directive to the settings.json file:
"php.validate.executablePath":"php"
the php binary must be properly available in $PATH on the Linux side.
And on Windows you need to have the path of the php windows version binary in the system environment variables, so that when you happen to be editing PHP files in the Windows File System - Not using the WSL remote - it uses the same binary.
This way you will have a VSCode that, when you are remote in WSL will use the proper lecture, being the same for when you are in Windows.

The fix for me was to download php for Windows into the folder c:\php and specify in Visual Studio Code settings.json:
"php.executablePath": "c:\\php\\php.exe",
I also added it to my Windows PATH environment variable.

Related

linux xammp Visual Studio Code configuration

I want to config Visual Studio Code (VSC) to work with php on linux (Ubuntu).
I installed xammp for this purpose and I don't know where to point this parameter on VSC php.validate.executablePath
On windows the config path has to be like this: "php.validate.executablePath": "c:/php/php.exe"
Could you give me the full path to configure it properly ON LINUX?
Regards
This answer may change based on what flavor of Linux/Unix you are using, but if you are using Ubuntu like me, this is how I did it.
First and foremost, I know you're using XAMPP, but do exactly what the error message says and install PHP7. You can do so by running sudo apt-get install php.
I know that goes against intuition. At first I thought "I have XAMPP installed, which installed PHP. Why do I need to install PHP?" XAMPP only includes the PHP runtime executables. In order to do development with PHP, you need to install the full environment. XAMPP will continue to use its built-in version.
Once the install is completed, follow these steps:
Execute whereis php. Example output below:
php: /usr/bin/php7.0 /usr/bin/php /usr/lib/php /etc/php /usr/share/php7.0-json /usr/share/php7.0-opcache /usr/share/php /usr/share/php7.0-readline /usr/share/php7.0-common /opt/lampp/bin/php /usr/share/man/man1/php.1.gz
In Visual Studio Code, click the cog in the bottom left corner and select Settings. On the right-hand pane, insert the following code. The version-agnostic path is used here:
"php.validate.executablePath": "/usr/bin/php"
Press Control+S or click File -> Save
The final settings file should look like this:
// Place your settings in this file to overwrite the default settings
{
// Snip... other configurations overrides
// Points to the PHP executable.
// Use the version-agnostic value from the "whereis php" command above.
"php.validate.executablePath": "/usr/bin/php"
}
For me is "/opt/lampp/bin/php" (I have xampp on Linux Mint; to find out write in terminal: "whereis php")

Php executable for php-linter when using xampp (ubuntu) not working

As the topic sentence says. I'm using atom with linter-php in ubuntu with an xampp setup. PHP is located in the opt/lampp/bin folder when you've installed xampp in ubuntu 16 but atom isn't accepting it. "unable to get version" and "spawn php ENOENT." Anyone out there using this same setup? Which path did you use for the php executable? Alternatively: Should i just install php in the standard file directory outside of xampp as well and direct linter there?
This may have been a bit of a hack approach to fixing this issue but i just installed php7.0 outside of xampp again and directed the linter path there. Actually didn't have to direct it at all. As soon as i installed php from the terminal, the issue was fixed.

Change PHP path in OS X terminal to XAMPP PHP

I just installed Composer on OS X 10.8 and am now trying to use it to install something else and it turns out my terminal is running php 5.3... In XAMPP I have 5.5, so I would like to just use that version in Terminal as well. I tried creating a .bash_profile in my home directory with
export PATH=/Applications/XAMPP/xamppfiles/bin/php-5.5.11/bin:$PATH
but that wouldn't work; which php still returns /usr/bin/php. What am I missing here? Much thanks in advance.
Here is my working Environment Path
export PATH="/Applications/XAMPP/xamppfiles/bin:$HOME/.composer/vendor/bin:/usr/local/sbin:$PATH"
Remember to wrap the path with double quotes and also close all terminal before checking the php version using
php -v or which php
If you aren't using a bash shell, then changing the bash_profile won't make a difference. bash apparently wasn't always the default, so on my mac, I am using .tcsh. I don't know why it uses one over the other, it has just always been that way (been upgrading macs since OS X 10.0). So on mine I have a .tcshrc file which operates like the bash_profile. In there I have
alias php /Applications/MAMP/bin/php/php5.6.7/bin/php
which you would obviously have to adjust to your own path and version, but you get the point.

Enable PHP support in PHPStorm Mavericks

To begin, I am not using MAMP or any LAMP.
I have PHPStorm and I want to add my php installation as an interpreter. When I choose the correct folder: "/usr/local/php5" or "/usr/local/php5/bin", PHPStorm gives me an error: PHP version: not installed.
However, both via the browser or the command line (php -i), both of my php installations are the same and the php.ini location for both is located at:
/usr/local/php5/lib
Why is PHPStorm not recognizing my PHP installation ? What am I missing ?
Edit1:
Run the following command in the terminal and use the output path as the path of your interpreter.
which php

Installing Xdebug for PHP on Ubuntu with XAMPP

I'm running XAMPP 1.7.3a on Ubuntu 9.10. With Netbeans 6.7.1 as my editor, I want to be able to debug my PHP sites.
To do this, I looked up Xdebug and started following the installation instructions, found here: http://xdebug.org/docs/install.
Trying to compile the .tgz file, run in to a problem.
Step 3) I can execute that, but what use does it have? I don't get the output or what I should do with it.
Step 4) I execute the following command:
./configure --enable-xdebug --with-php-config=/opt/lampp/etc/
At the bottom of the output, it says: configure:
error: Cannot find php-config. Please
use --with-php-config=PATH
I've checked the location I entered, the php.ini file is there and so are all other config files.
So, I'm not sure what to do now. Should I ignore and just do the 'make' command, or does something else yet need to be done?
you have to pass the path to the php config binary - should be something like
/opt/lampp/bin/php-config
All the binaries in XAMPP are located in
/opt/lampp/bin
That's why if you work with XAMPP's PHP version you ought to proceed all operations using binaries from there.
For example, after installation of XAMPP it's possible to set path to it's PHP bin file.

Categories