Jump to content

Error Messages in Visual Studio Code.


LeonLatex
Go to solution Solved by maxxd,

Recommended Posts

I have installed a PHP Debugger in VSC. When I run PHP debug I get a message that PHP / Web server could not be found + this 3 error messages:

1 - "PHP executable not found. Install PHP and add it to your PATH or set the php.debug.executablePath setting".
2 - "Intelephense updated to 1.8.0. Support the development of this extension and access other great features by purchasing a license at https://intelephense.com."
3 - "Cannot validate since a PHP installation could not be found. Use the setting 'php.validate.executablePath' to configure the PHP executable."

I have installed Laragon web server and PHP. I dont have a clue whats wrong or what I am doing wrong. Where to begin? Any suggestions?
Where I'll enter the path, I'm also unsure about (I'm very excited about Laragon, until now). Anyway, .... I dont want to replace it.)

Edited by LeonLatex
Link to comment
Share on other sites

1 hour ago, requinix said:

Both of the messages there (the two that are actual errors, that is) tell you what to do. Have you done that?

Yes, of course. Thats why i am asking. Beside, I also said so in my opening post. Just cant understand whats wrong😮🙄
I have also tried to reinstall everything more than once. I suspect it's not just me who has had the same problem. I am stucked again.

Heres some of what I wrote earlier:

9 hours ago, LeonLatex said:

I have installed a PHP Debugger in VSC. When I run PHP debug I get a message that PHP / Web server could not be found + this 3 error messages:

I have installed Laragon web server and PHP. I dont have a clue whats wrong or what I am doing wrong. Where to begin? Any suggestions?
Where I'll enter the path, I'm also unsure about (I'm very excited about Laragon, until now). Anyway, .... I dont want to replace it.)

image.png

Edited by LeonLatex
Link to comment
Share on other sites

This is the default path I have specified in the Visual Studio Code debugger. That is, under preferences in the debugger in Visual Studio Code debugger. That is, under preferences in the debugger , the same directory I have unziped the files to: C:\laragon\bin\php\php-8.1.2-nts-Win32-vs16-x64. So i dont understand what i could have done wrong there.
In Laragon is the "php-8.1.2-nts-Win32-vs16-x64" directory selected under" Menu->PHP->php-8.1.2-nts-Win32-vs16-x64

It seems like there is no connection betwen PHP and VSC.

I am emty of ideas. (please help)

Link to comment
Share on other sites

1 hour ago, requinix said:

So if you open up your user settings, let's say the JSON file, you can see in there an entry for php.debug.executablePath with the correct file path? And another entry for php.validate.executablePath with the same file path?

Before i have only checked the preferences field for the path. Now i opened the JSON file, and guess what, there is nothing there about the PHP path. Only the loop back address for Laragon and....... Look for your self:

{
     "workbench.colorTheme": "Default High Contrast",
     "security.workspace.trust.untrustedFiles": "open",
     "phpserver.ip": "127.0.0.1"
}

Edited by LeonLatex
Link to comment
Share on other sites

Read. The. Error. Messages.

12 hours ago, LeonLatex said:

1 - "PHP executable not found. Install PHP and add it to your PATH or set the php.debug.executablePath setting".
3 - "Cannot validate since a PHP installation could not be found. Use the setting 'php.validate.executablePath' to configure the PHP executable."

Please don't make me bold the relevant parts.

Link to comment
Share on other sites

1 hour ago, LeonLatex said:

This is the default path I have specified in the Visual Studio Code debugger. That is, under preferences in the debugger in Visual Studio Code debugger. That is, under preferences in the debugger , the same directory I have unziped the files to: C:\laragon\bin\php\php-8.1.2-nts-Win32-vs16-x64. So i dont understand what i could have done wrong there.
In Laragon is the "php-8.1.2-nts-Win32-vs16-x64" directory selected under" Menu->PHP->php-8.1.2-nts-Win32-vs16-x64

It seems like there is no connection betwen PHP and VSC.

I am emty of ideas. (please help)

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

A Path to an actual file will be C:\Program Files\php-8.1.2-Win32-vs16-x64\php.exe

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.

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

  • 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:
C:\laragon\bin\php\php-7.4.19-Win32-vc15-x64\php.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
      • 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"
      • Once you have made this folder, open it as the project folder in Vscode
      • 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

 

 

 

Link to comment
Share on other sites

18 hours ago, gizmola said:

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

A Path to an actual file will be C:\Program Files\php-8.1.2-Win32-vs16-x64\php.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:\laragon\bin\php\php-8.1.2-nts-Win32-vs16-x64\php.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 Files\php-8.1.2-Win32-vs16-x64\php.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:\laragon\bin\php\php-7.4.19-Win32-vc15-x64\php.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:\Users\kjeti\OneDrive\Dokumenter\www
      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 🤪

 

 

 

 

Link to comment
Share on other sites

gismola, maybe this screen shot will help you. Regardless of what kint of path i try to use this message pops up when i hold the pointer over the line.

I am sure that path is right. That is where the PHP directory with the php.exe is. But, can you se something else is wrong?

 

2022-02-06.png

Edited by LeonLatex
Link to comment
Share on other sites

On 2/6/2022 at 3:34 PM, maxxd said:

You also need to escape the slashes in your path.

When you say escape the slashes in the path i asume you mean put the whole string in double quotes. But the path is already in double quotes. So, exactly, what did you mean? Maybe I remember wrong or misunderstand the meaning of the word escape in this connection.

Link to comment
Share on other sites

  • Solution

No, backslash is an escape character. Note how every character after a backslash is red in your screencap - that means it's being interpreted as a command character (tbh I'm not sure that's the right term - it's being interpreted as something other than a simple character in a string). So where you have `\`, you should have `\\` - this will escape the second backslash and make the interpreter read it as a character in a string. So, basically

"C:\Program Files\your\path\php.exe"

becomes

"C:\\Program Files\\your\\path\\php.exe"

 

Link to comment
Share on other sites

  • 3 weeks later...

Yes, the setting can be fixed with the double backslashes.  This is because in windows the backslash is a separator for directory pathing, whereas in PHP it is used to escape characters in strings.  With that said, this setting gets disabled entirely when you follow the inteliphense directions, because it is used in a disabled plugin.  Get it "working" if you like but the setting isn't used, and you should probably just delete it entirely, and disable the plugins as I stated previously.

  • Great Answer 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.