Recently I updated my VS code on my macOS. I'm now running vs code version 1.41.1.
Ever since the reinstall, the phpfmt extension is no longer working and giving me the
phpfmt: php_bin "php" is invalid`
pop up every time I save a file.
I tried removing VS code and installing it again. I removed the extension and reinstalled it as well yet I am still getting this error.
Is there any other settings i can clear. I can't find this error anywhere online.
Just add below code in setting.json in VS Code
"phpfmt.php_bin": "C:/xampp/php/php.exe"
in my case the location is in xampp so just add your php.exe location.
On Mac Os:
In the vscode settings (JSON view) extend the ^^ above option with the Mac Os PHP path:
"phpfmt.php_bin": "/usr/bin/php"
Cheers
assuming you have PHP installed:
Edit your vscode settings (JSON view) add this option:
"phpfmt.php_bin": "php"
If you want auto formatting on save:
All Languages:
"editor.formatOnSave": true
Just PHP:
"[php]": { "editor.formatOnSave": true }
you can always check out the plugin page too:
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
has this bits of info on this + further configuration
happy coding!
You have to find dir to file php.exe and then you can fig that easily by this way below:
"phpfmt.php_bin": "F:/Xampp/php/php.exe",
F:/Xampp/php/php.exe - my directory
"phpfmt.php_bin": "C:/xampp/php/php.exe"
open setting.json in VS code
You have to find your php.exe path and paste it after "phpfmt.php_bin": "php.exe path"
We have composer as our dependency injection framework which will pull in a library we created, foobar, which works fine. The library foobar has 14 version v1.1.1 -> v1.1.14. All the way up to .12 composer updated the app fine. But now we are getting this error:
Update failed (Source directory /home/username/dev/git/appname/vendor/foorbar/library has unpushed changes on the current branch:
Branch v1.1.14 could not be found on the origin remote and appears to be unpushed)
The composer.json:
{
"name": "App",
"description": "Foo Bar",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.2.",
"foobarzf2lib/library": "v1.1."
},
"minimum-stability": "stable",
"repositories": [
{
"type": "package",
"package": {
"name": "foobarzf2lib/library",
"version": "v1.1.14",
"source": {
"url": "https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/foobarzf2lib",
"type": "git",
"reference": "test"
},
"autoload": {
"psr-4": {
"FooBar\\" : "FooBar/"
}
}
}
}
]
}
More things to know:
Vendor is ignored in git.
Tried doing $ composer.phar clearcache.
Would be ideal to not have to delete the library every time.
Remove vendor folder and reinstall packages.
Branch v1.1.14 could not be found on the origin remote and appears to be unpushed)
This means that wherever you're pulling the package from does not have a v1.1.14.
Make sure you push v1.1.14 to the package provider and everything should be fine.
Composer treats the local repository (the one inside the vendor folder) as leading. Whenever composer thinks it is not connected any longer (or diverged) for the checkout in place, it refuses to update (which I think is good and sane).
This may seem cumbersome but that is perhaps the price to pay for the ease of use. Composer is actually managing that git checkout while taking care of updates (it has various remotes configured and then a cache, all without additional setup).
In my case I can see similar errors (not the exact error message as asked about, I get a notification one or some files were changed without any direct changes when the remote did change non-fast-forward) and I resolved it the following way (perhaps it works in case of a missing branch, too? Nevertheless reviewing the issue with a git command similar to the following might shed better insights):
git -C <path> pull && composer update
Could work then, where <path> is the directory path given in composers' error message. If it does not, a more specific error message from git hopefully says more.
Point in case is that you need to resolve the version conflict before composer continues. That is similar when you have a merge conflict in git, you can't do the next commit without resolving it as otherwise you'd have files in the repository with merge conflict markers (and won't compile).
In case of interest, one aspect of my git configuration is pull.rebase=merges. That is in principle to do a rebase on pull (IIRC perhaps preserving some merges).
As an alternative - and similar to removing the whole vendor folder - removing just the reported path should work. As this is git, that repository is gone and as composer was concerned of it, it is not any longer:
rm -rf -- <path> && composer update
where <path> is (must be) the path in the composer error message. Take care with rm -rf, it can be easily over-reaching - just fyi.
(this is similar to the reported resolution in composers issue tracker)
I have a development environment based in docker.
Everytime that I open VSCode I get this message:
Cannot validate since no PHP executable is set. Use the setting
'php.validate.executablePath' to configure the PHP executable.
Somebody know how to set php.validate.executablePath in this case?
I have no idea how to do it.
Here is a screenshot.
Don't forget to escape \
You don't have to add it to the Path
For linux users:
if you don't have PHP installed then first download, then in terminal type
$ whereis php
and it will show path for php executable (It will be either in /usr/bin/php or usr/local/bin/php) which you can copy from terminal.
In VScode goto settings.json file and paste
php.validate.executablePath: /usr/bin/php
In my case using XAMPP is like this
"php.validate.executablePath": "C:/xampp/php/php.exe"
hope that answer your question
Sure, easy. Just follow what it's says.
Go to File> Preferences > Settings ... it will open the settings.json file.
add the following code:
{"php.validate.executablePath": "Here you put your PHP.exe path"}
You have to know where te PHP.exe file is in your computer, search in the php>bin folder.
Hope it works for you
I had the same problem but found the fix here.
In Windows:
Go To System Properties
Go To Advanced Tab
Click "Environment Variables"
Select Path
Add a new path that points to your php 7 executable:
My case, I'm using Laragon, so you should search where is your php.exe.
By VSCode just add.
"php.executablePath": "C:\\laragon\\bin\\php\\php-7.2.19-Win32-VC15-x64\\php.exe"
on settings.json.
VSCode
Linux Users:
Step 1:
In your terminal type
whereis php
In my case "php: /opt/lampp/bin/php"
Step 2:
{
"php.validate.executablePath": "/opt/lampp/bin/php"
}
Download PHP, in my case, I downloaded from here:
http://windows.php.net/download/
Copy and paste the files to a location on your computer, and set the path:
"php.validate.executablePath": "C:/php/php.exe"
"php.validate.executablePath": "C:/php/php.exe" wont work due to incorect escaping
try this;
"php.validate.executablePath": "C:\\php\\php.exe"
If you get this on windows in VS code click on the blue 'open settings' button. Near the bottom of the screen this opens there's a link to enter the settings, click this to open the settings.json file. Edit the file to look like this:
{
"php.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe",
"php.validate.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe"
}
where C:/php-7.4.2-nts-Win32-vc15-x64 is the path to your PHP dir
I don't know if this helps but I ran into the same problem with the extension PHP Intelephense in Visual Studio Code. What I did is read the instructions so the extension could work properly. So I disabled PHP Language Features by searching "#builtin PHP" in the extensions. Also, other (3rd party) PHP extensions that provide similar functionality should also be disabled for best results. Finally, I added glob patterns for non-standard PHP file extensions to the files.associations setting. For example: "files.associations": { "*.module": "PHP" }
Doing this made the error go away. I'm new to PHP too, let me know if this is the correct way of solving this problem with PHP Intelephense.
If you're using VScode and have installed Php through MAMP, the default path should be:
C:/MAMP/bin/php/php7.4.1/php.exe
/ not \
Regarding the docker-specific revision of the question, I found this thread in the VS Code PHP Intellisense git repo issue that explains how to create a wrapper script. It will involve mapping volumes, though, so take that into account.
https://github.com/felixfbecker/vscode-php-intellisense/issues/150#issuecomment-330374124
I have ubuntu and XAMPP.
The following worked for me.
Press CTRL + P
Type settings.json and hit ENTER.
Add the following line in settings.json
{
...
"php.validate.executablePath": "/opt/lampp/bin/php",
...
}
Make sure to proper syntax.
I simply used double forward slashes and it worked, like so:
"php.validate.executablePath": "C:\\xampp\\php\\php.exe",
Unix / Linux / Mac / WSL ,
Step 1 : Find PHP path
whereis php
Response will show you where your php directories are.
user#User:~$ whereis php
php: /usr/bin/php /usr/bin/php8.0 /usr/bin/php8.1 /usr/lib/php /etc/php /usr/share/php8.0-opcache
/usr/share/php8.0-xml /usr/share/php8.1-curl /usr/share/php8.1-opcache /usr/share/php8.0-gd
/usr/share/php7.0-gd /usr/share/php7.0-common /usr/share/php8.0-readline /usr/share/php8.0-mysql
/usr/share/php8.0-zip /usr/share/php8.1-mbstring /usr/share/php8.1-xml /usr/share/php8.0-mbstring
/usr/share/php8.0-common /usr/share/php8.0-curl /usr/share/php8.1-readline /usr/share/php8.1-common
/usr/share/man/man1/php.1.gz
Step 2 : Configure VS-Code
Go to -> "Preference -> Settings"
Search for -> "php path"
Then click -> "Edit in settings.json"
In my case I had multiple.So I chose the one I wanted from the available versions and my VS-Code looked like this
"php.validate.executablePath": "/usr/bin/php8.1",
IF using Laragon...Dont forget to change \ to /
"php.executablePath": "C:/laragon/bin/php/php-7.4.5-Win32-vc15-x64/php.exe",
Go to 'Preference' -> 'Settings'
Search for> php path
Then click Edit in settings.json
Then just put your directory with (DOUBLE Backslash).
Here is an example of mine:
C:\\php\\php.exe
Here is the format:
drive:\\folder_name\\php.exe
This should fix the problem.
php.validate.executablePath in laragon
In my case using laragon is like this
"php.validate.executablePath": "C:\\laragon\\bin\\php\\php-7.4.19-Win32-vc15-x64\\php.exe"
php-7.4.19-Win32-vc15-x64 : Note that this part of your file name may be different
I also had this error. I have installed Laragon and this addition in setting.json worked for me.
"php.executablePath":"C:/laragon/bin/php/php-7.2.19-Win32-VC15-x64/php.exe"
"php.validate.executablePath": "C:\xamp\php\php.exe"
this is working for this case
For Wampserver:
Inside settings.json
"php.validate.executablePath": "C:/wamp64/bin/php/php7.4.26/php.exe"
If php is inside a docker container and you don't need it or don't want to install it on you local system, you can create a php wrapper script like it is suggested here: https://github.com/felixfbecker/vscode-php-intellisense/issues/471
I prefer to use the remote container Microsoft extension on vscode and work inside the container itself.
I've used such solution:
First, create a php file inside /usr/local/bin/ and make it executable:
sudo touch /usr/local/bin/php
sudo chmod +x /usr/local/bin/php
Update content of it with:
docker exec $(docker ps --filter name=-app --format '{{.ID}}') php "$#"
So this will find a container with the name -app at the end. I'm using it along with the docker compose where I have php inside some container which has -app at the end of the name. You can check more about filter here.
And then update php.validate.executablePath with /usr/local/bin/php:
{
"php.validate.executablePath": "/usr/local/bin/php"
}
I also got this error message. The path to php.exe was already set in my System Environment Variables.
The error went away when I commented out "php.validate.executablePath": "c:/path/to/php7.2.10/php.exe", in the settings.json file in VSCode.
I have a problem to update dependencies in my project. Issue:
Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
In some cases It's only because of poor or interrupted internet connections
One solution might be changing your internet form Wi-Fi to Ethernet.
If you are using ESET antivirus, go in "Advanced Settings" and disable "HTTP-scanner" under "web access protection"
If you're using Virtualbox, Then you might need to downgrade to resolve the issue
If you are using IPv6, try disabling it.
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
If you are using ESET antivirus, go in "Advanced Settings" and disable "HTTP-scanner" under "web access protection"
If you are using IPv6, try disabling it. If that solves your issues, get in touch with your ISP or server host, the problem is not at the Packagist level but in the routing rules between you and Packagist (i.e. the internet at large). The best way to get these fixed is raise awareness to the network engineers that have the power to fix it.
To disable IPv6 on Linux, try using this command which appends a rule preferring IPv4 over IPv6 to your config:
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
I had this issue too, it ended up being a Virtualbox issue. I needed to downgrade to version 5.1.6 to resolve it. (I was running 5.1.8)
Also, I read that running 5.0.28 also caused this issue, and downgrading to 5.0.10 resolved it.
Add these lines in composer.json and then run composer update.
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]
Happy coding!
I installed phabricator on openshift using a quickstart from github
https://github.com/CodeBlock/phabricator-openshift-quickstart
I got it running up fine, but I now have two issues:
1.) A setup issue that says apc.stat is enabled and that must be disabled in
/var/lib/openshift/my-user-hash/php/configuration/etc/php.ini
however I cannot access that with sudo command(sudo permission denied), even if I open it normally, I didn't find any apc.stat settings in the php.ini
2.) I can't figure out how set the local path for tracking repositories for diffusion. It says
I must give a path which should be read-writable by phabricator, I tried to give the persistent storage location ..data/ , but it gives me an exception as follows :
Unhandled Exception ("CommandException")
Command failed with error #1!
COMMAND
(cd '../data/' && HOME='/var/lib/openshift/my-user-hash/app-root/runtime/repo/phabricator/support/empty/' git cat-file --batch)
STDOUT
(empty)
STDERR
sh: line 0: cd: ../data/: No such file or directory
how do I fix this?
1) According to Num Duong answer, it seems like u currently could not resolve this issue, probably u should wait for openshift php.ini permissions policy changes.
Anyway this is minor non blocking issue.
2) Modify config file and re-deploy to openshift.
Look for available phabricator options here
U need smth like this: 'repository.default-local-path' => getenv('OPENSHIFT_DATA_DIR'),
P.S. Anyway there is one particular issue with phabricator on openshift that possibly never got resolved: cloning git repositories from OpenShift instances into Phabricator do not
work by SSH, due to permissions regarding the ssh configuration.