PHP IntelliSense on Fedora, executable not found - php

I have Visual Studio Code installed on Fedora V 36. Even though I've set the php executable in the setttings.json file I'm still getting
PHP executable not found. Install PHP 7.4.0 or higher and add it to your PATH or set the php.executablePath setting
settings.json
{
"php.executablePath": "/usr/bin/php",
"php.validate.executablePath": "/usr/bin/php",
}
whereis php shows
php: /usr/bin/php /usr/lib64/php /usr/share/php /usr/share/man/man1/php.1.gz
php -v shows
PHP 8.0.24 (cli) (built: Sep 28 2022 15:32:34) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.24, Copyright (c) Zend Technologies
The question is, how can I get VS Code, or rather IntelliSense, to recognize the php executable?

The answer was that VsCode was having a permission issue with the php executable, due to VsCode being installed from Flatpak.
After some trial and error I ended up uninstalling the Flatpak version of VsCode and re-installing with directions from the official site.
https://code.visualstudio.com/docs/setup/linux#_rhel-fedora-and-centos-based-distributions

Related

PHP "Undefined" errors after installing Laravel in VS Code

All I did was create a new Laravel project with composer create-project laravel/laravel games_review and I started getting these errors without touching a single line in the PHP code.
I also see a VS Code error that says
The PHP Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted.
Source: PHP IntelliSense (Extension)
I have PHP in my path and when I type php -v into the console, it says
PHP 8.0.3 (cli) (built: Mar 2 2021 23:34:05) ( ZTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
In VSCode, I have three PHP extension packs installed
PHP Intelephense
PHP Debug
PHP IntelliSense
I have nothing related to PHP in my VSCode settings.json file

PHPUnit error - Can't run Laravel tests from Command line using MAMP Server

I've been having this issue for quite some time now. First of all, I have MAMP Pro Server installed on my Mac OS and the default PHP Version selected is 7.3.8. I have also checked the 'Make this version available on the command line' option. But whenever I try to run laravel tests using the phpunit command, I get the following error;
PHPUnit 8.4.3 by Sebastian Bergmann and contributors.
This version of PHPUnit is supported on PHP 7.2, PHP 7.3, and PHP 7.4.
You are using PHP 7.1.16 (/usr/bin/php).
I have confirmed my php version on available on the command line using php -v an it outputs
PHP 7.3.8 (cli) (built: Aug 14 2019 16:42:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
Please kindly help.
Your /usr/bin/php file does not link to your MAMPs version of php. This file is used by phpunit (in your case).
Let me tell you how you can switch it:
First of all, move away the original link
sudo mv /usr/bin/php /usr/bin/php.bak
Then link /usr/bin/php to your actual MAMP PHP version:
sudo ln -s /Applications/MAMP/bin/php/php7.3.8/bin /usr/bin/php
Validate it with /usr/bin/php -v giving you the 7.3.8 version.

Laravel 5.4 with MongoDB MAC Mojave

Hello I having trouble to to install "jenssegers/mongodb": "^3.2" on my local environment.
i have this error:
I have added to my /etc/php.ini full path to extentions="/usr/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so"
restart the php and apache
I have try to find mongodb.ini, fail on that.
I try all the tutorial is google... still no luck
Can any one help me please?
PHP 7.1.23 (cli) (built: Feb 22 2019 22:08:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
It seems that you forgot to install MongoDB PHP Driver itself.
To do that just install it with pecl:
sudo pecl install mongodb-1.5.3
1.5.3 is the last stable version, so I'd recommend to use it rather than the most recent 1.6.0alpha.
Then, don't forget to add it to your php.ini (run php --ini to see where it's located):
extension=mongodb.so
To test that it works just run:
php -m | grep mongo
If you see mongodb in output, then it works.

Why is php zip extension not working on ubuntu though it's installed?

I'm on Ubuntu 16.04 and I'm trying to install prestashop e-commerce CMS that requires php zip extension to unzip the main CMS folder.
I have installed php-zip and php7.2-zip and I also restarted the web server (apache2) but the CMS still displays the following message
An error has occured:
You must install PHP zip extension first
Here's the result of my installed php zip packages and my current php version:
eljaouhari#eljaouhari-HP-350-G1:/var/www/html$ php -v
PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 5 2018 04:59:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
eljaouhari#eljaouhari-HP-350-G1:/var/www/html$ apt list --installed | grep php | grep zip
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
php-zip/xenial,xenial,now 1:7.2+60+ubuntu16.04.1+deb.sury.org+1 all [installé]
php7.2-zip/xenial,now 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installé]
I spent an hour and a half trying to figure out whether I need to activate the extestion on the php.ini file and also installing and reinstalling and restarting the web server but nothing seems to work.
I have tried a few solutions on the web that used to work for me but I can't seem to find a good solution.
Please help me with your experience!
I've found the solution after I printed the results of the phpinfo() function.
It seems that the version of php printed with the "php -v" command is not the version that actually apache is using. Apache ended up using the 7.0 version.
Thanks everyone.

PHP --version shown incorrectly on osX

I've installed in my osX php7 from homebrew, however when I type in the shell eitherphp --version or php-fpm --version I get as result an older version
PHP 5.5.30 (fpm-fcgi) (built: Oct 23 2015 17:22:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
From the shell I looked for every php file or folder sudo find / -name "php" but nothing linked to PHP 5.5
What should I do?
After creating ~/.bash.profile as written in comments by Michael, I found the solution thanks to change the PHP path to MAMPs PHP
In ~/.bash_profile I wrote:
export PATH=/usr/local/Cellar/php70/7.0.2/bin:$PATH
export PATH=/usr/local/Cellar/php70/7.0.2/sbin:$PATH
First row is for php, the second for php-fpm
Then, to be sure that changes take effect type in terminal source ~/.bash_profile

Categories