Php not found php server ошибка

I’m trying to learn PHP and am encountering some issues early on. When I setup my basic file, then select PHP serve project, I receive a message at the bottom right of the screen saying PHP not found. I’ve setup my settings for the default xampp php file folder location with the command: «php.validate.executablePath»: «c:xamppphpphp.exe»,

Pics are attached. Any help would be really appreciated.

JSON Settings

Basic PHP File

asked Apr 5, 2021 at 10:30

Ryan C's user avatar

5

Go to File->Preferences->settings->User settings tab->extensions->from the drop down select php->on the right pane under PHP › Validate: Executable Path select edit in settings.json.

Then set the path as your case may be for a XAMPP user who installed XAMPP on c drive you will have:

"php.validate.executablePath": "c:\xampp\php\php.exe"

If PHP is installed in your system independently or by other means simply set the path of your php.exe file like below:

"php.validate.executablePath": "C://path.to.your.php.folder//php.exe"

Found this solution from php not found visual studio.

General Grievance's user avatar

answered Jan 26, 2022 at 8:42

Meher Ullah Khan Raj's user avatar

1

I am maybe late but the above solutions didn’t work for me. My solution was I went to File > Settings > enter php into the search field > enable Suggest and Validate and after just scroll down, let’s find the the config path and the php path fields and enter your path.

  • PHP Config Path C:laragonbinphpphp-7.4.19-Win32-vc15-x64
  • PHP Path C:laragonbinphpphp-7.4.19-Win32-vc15-x64php.exe

and that’s worked for me.
I hope I can help you.

answered Dec 15, 2022 at 8:39

Dániel Molnár's user avatar

Go to the PHP Server extension setting. There you have to add the path for:

PHP Config Path: C:xamppphpphp.ini

PHP Path: C:xamppphpphp.exe

[Make sure to add your installed folder, if you have installed xampp in another drive, you need to give that specific location.]

My settings:

My settings screenshot here

Suraj Rao's user avatar

Suraj Rao

29.3k11 gold badges94 silver badges103 bronze badges

answered May 4 at 5:15

khalilonline99's user avatar

The PHP Server: Serve project command is not builtin. As the prefix suggests, it’s provided by the PHP Server third-party extension. The setting you changed doesn’t have anything to do with this feature.

You can find documentation on the extension settings on its Marketplace page, which can also be accessed right from the extension pane within Visual Studio Code.

  • Setting: phpserver.phpPath
  • Default: null
  • Notes: Path to PHP executable. If empty, the extension will try to get the path from the $PATH environment variable.

answered Apr 5, 2021 at 14:24

Álvaro González's user avatar

Álvaro GonzálezÁlvaro González

141k40 gold badges259 silver badges356 bronze badges

In VSCode go to File -> Preferences -> Settings

Then add this code

{
"php.validate.executablePath": "C:\xampp\php\php.exe",
"php.executablePath": "C:\xampp\php\php.exe"
}

answered Apr 5, 2021 at 10:38

Omar Tarek's user avatar

3

I also run into the same problem just now. This answer is for newer people who will came for the solution:

Put these two lines in your json settings

{
"php.validate.executablePath": "C:\xampp\php\php.exe",
"php.debug.executablePath": "C:\xampp\php\php.exe",
}

answered Jan 26, 2022 at 8:36

Meghanad Kheti's user avatar

Well, above didn’t work for me. I had to add environment variable for php path. My system — Win10 64bit, VScode v. 1.64.2

answered Jun 16, 2022 at 13:02

inquisitive's user avatar

1

I had to add environment variables to my windows 11 as well.

Environment variable is simply the path. For instance,

D:BackendXamppphp

Then type environment variables and select ‘Edit the system environment variables. Look for
Environment Variables > click path (Top) > Edit (from the top) > New and paste the path of wherever you installed your Xampp. Make sure to point to the php folder.

answered Feb 3 at 13:27

Nafiur Rahman's user avatar

I am working on a school computer and found a way to fix all of these problems for myself!

So when installing the «PHP Server» extension, you want to have PHP installed. After that is done you find the path to the PHP binary and add it to the executable path in the extension settings. I personally installed PHP to my USB drive since these computers always reset.

Hope this helps!

anurupr's user avatar

anurupr

2,2942 gold badges20 silver badges28 bronze badges

answered Feb 28 at 9:30

alexstokin420's user avatar

Probably late but leaving this here for the people who may encounter this in future,

If Nothing mentioned above is working for you then go to the PHP Server extension setting on marketplace and change the default null value of Phpserver: PHP Path to
c:xamppphpphp.exe
or whatever path your php.exe is in.
Hope that helps.

answered Apr 5 at 6:22

Anish Prasai's user avatar

If editing the settings.json file didn’t work for you, consider adding the php path into the «advanced system settings» of your windows device (hit Windows + R, then type sysdm.cpl)
Once there, go to Environment Variables and click on path, then edit. Within the path section, click on new and paste the path to your php folder (not to the .exe file), then hit okay.

answered Apr 5 at 11:59

Jaregui's user avatar

I’m on a windows machine, so I added the following key-value pair to the json file:

"php.validate.executablePath": "C://wamp64/bin/mysql/mysql5.7.36/bin/mysql.exe"

Trenton McKinney's user avatar

answered Apr 3 at 14:59

Paula Hill's user avatar

0

2 / 2 / 0

Регистрация: 03.12.2016

Сообщений: 45

1

13.09.2021, 18:47. Показов 7090. Ответов 8


Студворк — интернет-сервис помощи студентам

В VScode установил расширения php intelephense и php server. Также в настройках (в json файл) добавил:

«php.validate.executablePath»: «c:/php/php.exe»,
«phpserver.phpPath»: «c:/php/php.exe»

Предварительно разархивировав последнюю версию php для Windows х64 (разрядность совпадает. Проверил) здесь windows.php.net/download/

Но не смотря на это. На ноутбуке выдает ошибку PHP not found, когда я пытаюсь запустить PHP Server: Serve Project. Однако, повторив все те же действия на компьютере, я пришел к успеху

Может быть я что-то еще пропустил? Кто-нибудь сталкивался с этой проблемой?



0



189 / 136 / 36

Регистрация: 19.11.2020

Сообщений: 881

13.09.2021, 20:04

2

Так может нужно указать путь к php.exe а не сам файл?



0



2 / 2 / 0

Регистрация: 03.12.2016

Сообщений: 45

13.09.2021, 20:29

 [ТС]

3

@OpXiv, ну так я указал путь к exe

Цитата
Сообщение от Dolya08
Посмотреть сообщение

«php.validate.executablePath»: «c:/php/php.exe»,
«phpserver.phpPath»: «c:/php/php.exe»



0



ft4l

Невнимательный

2380 / 742 / 265

Регистрация: 08.02.2013

Сообщений: 5,045

Записей в блоге: 2

13.09.2021, 22:38

4

Цитата
Сообщение от Dolya08
Посмотреть сообщение

php server

Настройки там через File->Preferencess->Settings->>>Extensions->PHP_server_configuration

в setting.json если залезть то там в итоге такое у меня

Javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
    "window.zoomLevel": 1,
    "security.workspace.trust.untrustedFiles": "open",
    "workbench.activityBar.visible": false,
    "editor.fontFamily": "'DejaVu Sans Mono', 'Courier New', monospace",
    "editor.wordWrap": "on",
    "files.exclude": {
        "**/CVS": false
    },
    "editor.autoClosingBrackets": "always",
    "editor.autoClosingQuotes": "always",
    "editor.codeLensFontSize": 10,
    "telemetry.enableCrashReporter": false,
    "telemetry.enableTelemetry": false,
    "settingsSync.keybindingsPerPlatform": false,
    "window.autoDetectColorScheme": true,
    "workbench.colorTheme": "GitHub Light",
    "php.validate.executablePath": "c:/php-8/php",
    "launch": {
        "configurations": [
        
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 0,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        }
        ]
    },
    "phpserver.phpConfigPath": "c:/php-8/php.ini",
    "phpserver.phpPath": "c:/php-8/php.exe",
    "phpserver.browser": "c:/PF/Opera/Opera.exe"
}

создал файл 1.php

PHP
1
2
<?php
phpinfo();

В контекстном меню такое только

PHP not found

Проект не создавал и файл в браузере не хочет открывать.
Сервер запускает и останавливает.
php.exe в процессах висит
В браузере http://localhost:3000/ показывает

Not Found
The requested resource / was not found on this server.

Для какой папки запускает сервер не разобрался ещё



0



189 / 136 / 36

Регистрация: 19.11.2020

Сообщений: 881

13.09.2021, 23:45

5

Цитата
Сообщение от ft4l
Посмотреть сообщение

«php.validate.executablePath»: «c:/php-8/php»,

А я это и имел введу.



0



Невнимательный

2380 / 742 / 265

Регистрация: 08.02.2013

Сообщений: 5,045

Записей в блоге: 2

14.09.2021, 01:28

6

Цитата
Сообщение от OpXiv
Посмотреть сообщение

c:/php-8/php

это php.exe ) просто без .exe тоже можно



0



2 / 2 / 0

Регистрация: 03.12.2016

Сообщений: 45

14.09.2021, 01:37

 [ТС]

7

Т.е. разницы нету. Уже проверял



0



ft4l

Невнимательный

2380 / 742 / 265

Регистрация: 08.02.2013

Сообщений: 5,045

Записей в блоге: 2

14.09.2021, 03:50

8

Цитата
Сообщение от Dolya08
Посмотреть сообщение

Уже проверял

Php точно запускается ?
Запустите коммандную строку, выполните там
c:phpphp.exe -v или -i
Не помешало-бы посмотреть что за php с этим -v.
И не помешает переименовать там c:phpphp.ini-development в c:phpphp.ini
чтобы расширения можно было включать, уже не помню просило-ли VSCode каких нибудь расширений
Насколько понял жалуется на php.validate.executablePath
оно для проверки синтаксиса юзается

Не по теме:

Цитата
Сообщение от ft4l
Посмотреть сообщение

Javascript
28
           "port": 0,

Настроил у себя PHP-Debug
нужно было порт сделать 9000
и добавить туда же строчку «runtimeExecutable»:»c:/php-8/php.exe»,

сейчас такое

Javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
    "window.zoomLevel": 1,
    "security.workspace.trust.untrustedFiles": "open",
    "workbench.activityBar.visible": false,
    "editor.fontFamily": "'DejaVu Sans Mono', 'Courier New', monospace",
    "editor.wordWrap": "on",
    "files.exclude": {
        "**/CVS": false
    },
    "editor.autoClosingBrackets": "always",
    "editor.autoClosingQuotes": "always",
    "editor.codeLensFontSize": 10,
    "telemetry.enableCrashReporter": false,
    "telemetry.enableTelemetry": false,
    "settingsSync.keybindingsPerPlatform": false,
    "window.autoDetectColorScheme": true,
    "workbench.colorTheme": "GitHub Light",
    "php.validate.executablePath": "c:/php-8/php",
    "launch": {
        "configurations": [
        
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000,
            "runtimeExecutable":"c:/php-8/php.exe",
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        }
        ]
    },
    "phpserver.phpConfigPath": "c:/php-8/php.ini",
    "phpserver.phpPath": "c:/php-8/php.exe",
    "phpserver.browser": "c:/PFO/Opera/Opera.exe"
}

Закачал с https://xdebug.org/download dll для своей версии

PHP 8.0 VS16 TS (32 bit)
У меня всё (32 bit) на 7-ке 64-бит
и только TS-Версия php на виндовс может включаться модулем apache

Закинул эту dll в c:/php-8/ext и переименовал в php_xdebug.dll
В php после перечисления всяких расширений добавил 4 строчки

Assembler
1
2
3
4
5
6
7
8
;extension=php_xsl.dll
;extension=php_imagick.dll
zend_extension=php_opcache.dll
 
zend_extension=xdebug
[xdebug]
xdebug.mode=debug
xdebug.start_with_request=yes

Заработало.
И команда php -v в консоли стала выводить

Код

PHP 8.0.6 (cli) (built: May  4 2021 23:32:43) ( ZTS Visual C++ 2019 x86 )
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies
    with Xdebug v3.1.0beta2, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies



1



2 / 2 / 0

Регистрация: 03.12.2016

Сообщений: 45

16.09.2021, 09:17

 [ТС]

9

Цитата
Сообщение от ft4l
Посмотреть сообщение

Запустите коммандную строку, выполните там
c:phpphp.exe -v или -i
Не помешало-бы посмотреть что за php с этим -v.

Не смотря на то что я запускал cmd от админа. Мне выдает это сообщение
PHP Warning: ‘C:WindowsSYSTEM32VCRUNTIME140.dll’ 14.13 is not compatible with this PHP build linked with 14.29 in Unknown on line 0

После этого я начал искать кто сталкивался с этой проблемой. А всего-то нужно было установить Microsoft Visual C ++ Redistributable для Visual Studio 2019

После перезагрузки компьютера и VSCode’а, PHP server Заработал. Спасибо всем большое



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

16.09.2021, 09:17

9

@AnuragRai017

Issue Type: Feature Request

php not found

Extension version: 3.0.2
VS Code version: Code 1.56.2 (054a9295330880ed74ceaedda236253b4f39a335, 2021-05-12T17:13:13.157Z)
OS version: Windows_NT x64 10.0.19042

@KGrafton86

I had the same problem. Try pressing Ctrl+, to open your settings, then search for phpserver.phpPath and put in the path of your php executable. Can’t remember if I had to reload VS Code after.

image

@sm967

Having the same exact issue. I can confirm that my php.exe is working due to other extensions using it (and version checking it multiple times). I changed my settings.json file to include all of this just to be super sure:

«php.validate.executablePath»: «C:xamppphpphp.exe»,
«php.executablePath»: «C:xamppphpphp.exe»,
«phpserver.phpPath»: «C:xamppphpphp.exe»,

I tried making them all the surrounding folder rather than the .exe itself, enabled and disabled all builtin PHP functionality in VSCode, and still nothing. No matter how many times I restart or change things I can’t get the server to recognize php.exe. I even installed PHP separately and tried using that .exe instead with no luck. Any ideas?

@KGrafton86

The backslashes need to be escaped in the json file. Does your file look like the first line in this image or the second line?

image

If I don’t have the backslashes escaped, parts of the string show in different colors, but when I add the escape characters, it all changes to one color (I’m using the Dark+ (default dark) theme, strings in json show as orange). If yours looks like the top line, try adding the escape characters and see if it helps. It is possible that you’ve set up a different escape character for json, but is the default.

@sm967

I have had the characters escaped in my settings.json file since I started troubleshooting, still gives me the same error message every time. Any other ideas as to what I could be doing wrong?

image

@AlexanderAdelAU

PHP not found.
I have tried just about every possible setting as well. I hope the author is viewing these comments.

@ThnksCJ

i have this issue now, it worked before but now it says php not found?

@Muschke

Did anyone manage to solve this? I have the same problem with Ubuntu.

@diaspolistic

Running this command in the terminal worked for me (Ubuntu user)
sudo apt-get install php

@Muschke

Ofcourse php needs to be installed. I solved the issue by installing visual studio using the command line, instead of via the software center. I could set the path «/usr/bin/php» correct without having to disable the PHP features app.

@Guulik

Hello everyone, I had the same issue and the problem was that I specified the path in settings.json within the code runner extension and not for the whole vscode. Check to see if you accidentally wrote it in the wrong place too
изображение_2023-05-20_153428251

Nobody likes errors, least of all computer programmers!

If you are a PHP developer and recently installed Visual Studio Code (VS Code), then you are most likely getting a pesky «PHP executable not found» error message every time you start the program.

Some other VS Code error message you will see with the PHP executable not found message includes:

  • Install PHP 7 and add to your PATH»
  • «set php.executablePath setting»
  • «Cannot validate since no PHP executable is set»
  • «Use the php.validate.executablePath to configure the PHP executable»

With every single one of these VS Code error messages, you simply need to update your Windows PATH setting for your PHP executable location. Doing that will fix all of these PHP executable errors!

How to fix PHP executable not found error in VS Code

  • Install php on your computer (e.g. with XAMPP)
  • Locate your php installation directory
  • Open Advanced System Settings on Windows
  • Update the Windows «PATH» environment variable
  • Close VS Code and reopen it

Step 1: Install php on your computer (e.g. with XAMPP)

The first and very most important step to fix the PHP executable not found error on Visual Studio Code is to actually have PHP installed on your computer. Now that might seem like an obvious starting point, but you would be surprised how many people don’t have PHP installed on their local web dev environment (e.g. their localhost server).

install XAMPP on windows to install php

Personally, I have always been a fan of the XAMPP suite by ApacheFriends.org. I have been using the XAMPP suite to install PHP, MySQL, and phpMyAdmin for my localhost web servers for years. I highly recommend.

Step 2: Locate your php installation directory

Once you have PHP installed on your local computer (as part of your localhost server), you need to find the PHP installation directory. As we need the folder path that holds your php.exe file.

locate your php executable file

If you installed XAMPP, simply browse to your XAMPP installation directory. The default location is at C:xampp. From inside the XAMPP folder, open the PHP folder and locate the php.exe file. If you can find the php.exe file from in this folder, then this folder will be your php installation directory.

Step 3: Open Advanced System Settings on Windows

Now that we know your php installation directory, we need to open the actually add the folder path into the Windows’ PATH. But to get there, you have to open a few different screens.

From the your file explorer or desktop, right click on «This PC». Then select «Properties» from the drop down. Doing this will open the Windows control panel menu for your system settings.

From the system settings menu, you will see all of your computer’s basic information like RAM, CPU size, and your computer name.

On the left hand side of the program, you will see an option to open «Advanced System Settings». Go ahead and open the Windows advanced system settings program.

open the advanced system settings in Windows control panel

Please note: this WILL require you to have administrative permissions on your Windows computer. If you do not, then you will have to contact the person that does in order to update the Windows PATH variable.

Step 4: Update the Windows «PATH» environment variable

Once you have successfully found and opened the Windows advanced system settings popup, you can edit your Windows environment variables. While selected to the Advanced tab in the popup, click on the «Environment variables…» button at the bottom. This will open another program.

update your path variable to save the location of the php executable

From here you can update all of your Windows environment variables. But in order to fix the PHP executable not found error message in VS Code, we really only care about the PATH variable.

So, from the list of User variables, select the «Path» option. Then click the Edit button. This will open the variable editor window.

Inside of the variable editor window, you can create a new PATH variable quite easily. Simply click the «New» button on the right hand side. Then enter in your PHP installation directory that we got from the step above.

Be sure to click away from the new path you created to ensure the updated PHP path is correctly saved into Windows.

Step 5: Close VS Code and reopen it

When you have successfully saved your PHP path location into the Windows PATH variable, you can close out of all of the Windows control panel windows.

You can now close VS code and reopen it. And you will notice that you have gotten rid of the «PHP executable not found» error message that you get on VS code start up. Great success!

Those are not paths under windows.  Under windows a path looks something like:  C:Program Filesphp-8.1.2-Win32-vs16-x64

A Path to an actual file will be C:Program Filesphp-8.1.2-Win32-vs16-x64php.exe

So if this isnt a path, you got to tell me. Unfornatley i forgot to write php.exe in the end here on PHP Freaks But the rest of it looks wery similar to what you tell me gizmola. So sorry for not add php.exe if it misled you, wery sorry 😣
C:laragonbinphpphp-8.1.2-nts-Win32-vs16-x64php.exe — and this is how the line looks like now in mine VSC. I have tried without php.exe to. Another thing i tried in an attempt of blindfolded was this:  «php.validate.executablePath»: «
C:Program Filesphp-8.1.2-Win32-vs16-x64php.exe» . 
None of them works. But if one of them should still be correct, please tell me which ones. Then I know I’m on the trail of something, at least.

1st things 1st!

You are using the Inteliphense plugin.  If you navigate to the instructions it tells you to disable the builtin php Language Features extension.  That setting points to a local cli php for linting.  Inteliphense doesn’t use that, so it doesn’t matter.  Disable the builtin and the message will go away.

It was a shot in the air, just to try it. It was in the same

Based on what you’ve said you installed Laragon.  Which version did you install?  There is a full version and a portable version.

I am using the full version. #5.0.0. 210523

  • There are really 2 forms of PHP.  PHP in a webserver, that is handled for you by your Laragon install and the php CLI program that you would run in a command,cmd or powershell, and that I guess vscode wants a path to. 

    • You don’t really need this to write code.  With that said, most likely the path to your php is this:

      I dont know if this tell you anyrhing about your question, but the PHP version i use is: php-8.1.2-nts-Win32-vs16-x64 

C:laragonbinphpphp-7.4.19-Win32-vc15-x64php.exe

Some things to understand:

  • You don’t need vscode integration to use it for PHP development.  This is especially true if you’re developing a web app.  The php files just need to be in the right place so the webserver can process them.
  • Laragon makes this structure for you:

    • c:/laragon/www This is one of the most important things why I use Laragon Webserver. In Laragon it is easy to change the root folder (www) and it is stable when done. My www root folder is: C:UserskjetiOneDriveDokumenterwww
      And as I have told you before i have no problem to access .php files with my browser.

      • You can see this in the laragon app by clicking on the little gear, and it will be listed as the webroot.
      • For your project(s) make a directory with Vscode inside that folder.  Name it whatever you want but I would suggest not using spaces or non-ascii letters in your directory names, although you can.
      • use Vscode’s new directory button or menu choice to make your project folder inside c:/laragon/www.

        • For this example, assume your folder is named «test» Thats right 👍
      • Once you have made this folder, open it as the project folder in Vscode
        Can i set the www folder as a project folder? I have about ten other folders in there wich is different projects.
         
      • Create a new folder named public

        • Usually you want your webroot to be a directory beneath your project folder.  There are a few different conventions, but /public is a common one.   Create a new index.php file that just has this in it

          • <?php phpinfo(); 
      • Navigate to it with your browser specifying the hostname of «localhost».  If you get the php info page, then everything is working and you can now add/edit through vscode and should see your changes reflected in your browser.
  • xdebug is hard to get working for many people

    • For web development, again, in order for VSCode to be able to debug and make the connection between source files on your workstation and the programs running within the browser, you have to have everything configured perfectly or it won’t work.
    • You need a strong understanding of networking concepts and be able to configure the xdebug.ini appropriately for your system
    • the xdebug extension has to be available, configure to work in your php environment, and have the right .ini settings
    • For vscode you also need an xdebug plugin and the right settings
  • You don’t need xdebug to get started with php development.  There are many other ways to debug your problems without an integrated debugger, even though it is a really nice tool to have for you in some situations.  I rarely have felt like I really needed xdebug for day to day php development .

    Yes, that because you are a bether PHP developer than me. Remember i have to learn everything up again after 11-12 years without any developing and coding. So there is a reason for everything.I am one of thosw pweople it is hard for 🤪

Понравилась статья? Поделить с друзьями:
  • Photoshop не открывает pdf ошибка диска
  • Photoshop exe ошибка приложения 0xc0000142
  • Photoshop exe ошибка приложения 0xc000007b
  • Photoshop cs6 ошибка при запуске приложения 0xc000007b
  • Photon launcher phasmophobia произошла одна или несколько ошибок