How do i enable php validation in visual studio code?

How do i enable php validation in visual studio code?

Did you find this message when creating a PHP file in VSCode?

Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.

1. First of all

Open settings.json and paste this line "php.validate.executablePath": "your_unit:/xampp/php/php.exe", paste this in the last line of your settings.json.
Ok, the annoying message does not pop up anymore, and now?.

That's all

not kidding really😄 but... we want to debug PHP also in VSCode right?.

2. CRTL+SHIFT+P

type ext install PHP Debug and install the first match.

Run XAMPP server, create a php file like test.php with phpinfo(); open it in your browser localhost/test.php copy the HTML source (what you see) and paste it into here: xdebug.org/wizard now hit analise my phpinfo() output.
Follow the instruction and download the .dll file, install it in the folder your_unit:\xampp\php\ext .

3. Almost done!

Now open you php.ini from XAMPP and paste the code in the very last line

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
zend_extension = "you_unit:\xampp\php\ext\downloadedfile.dss

Save it!

Now, restart XAMPP and VSCode and you should be done!

Last thing

Wondering how it works?
Open your project on your browser, set a stop point in VSCode and see the magic!

You can follow the documentation at xdebug.org and also at VSCode extension page.

Thanks for read, it's my really first post

 

PHP Programming in VS Code

Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense, and snippets out of the box and you can add more functionality through community created VS Code extensions.

How do i enable php validation in visual studio code?

Snippets

Visual Studio Code includes a set of common snippets for PHP. To access these, hit kb(editor.action.triggerSuggest) to get a context specific list.

How do i enable php validation in visual studio code?

Linting

VS Code uses the official PHP linter (php -l) for PHP language diagnostics. This allows VS Code to stay current with PHP linter improvements.

There are three settings to control the PHP linter:

  • php.validate.enable: controls whether to enable PHP linting at all. Enabled by default.
  • php.validate.executablePath: points to the PHP executable on disk. Set this if the PHP executable is not on the system path.
  • php.validate.run: controls whether the validation is triggered on save (value: "onSave") or on type (value: "onType"). Default is on save.

How do i enable php validation in visual studio code?

To set the PHP executable path, open your User or Workspace Settings and add the php.validate.executablePath:

{
    "php.validate.executablePath": "c:/php/php.exe"
}

Extensions

There are many PHP language extensions available on the VS Code Marketplace and more are being created. You can search for PHP extensions from within VS Code by running the Extensions: Install Extension command (kb(workbench.action.showCommands) and type ext install) then filter the extensions drop down list by typing php.

How do i enable php validation in visual studio code?

Debugging

PHP debugging with XDebug is supported through a PHP Debug extension. Follow the extension's instructions for configuring XDebug to work with VS Code.

Next Steps

Read on to find out about:

  • Extension Marketplace - Browse the extensions others have shared
  • Debugging - Learn more about VS Code debugging

Setting PHP validation to false in Preferences/User settings.json and/or Preferences/Workspace settings.json does currently work in Windows (year 2016, VSC Version 1.4.0) to end the validation messages. User preference settings are applied globally, while Workspace settings are applied to specific folders or projects.

Just to clarify what may not be obvious to newbies, custom settings in User 'settings.json' and Workspace 'settings.json' pages must be bracketed, otherwise the defaults will not be overwritten.

After the settings have been entered, the page must be saved (File/Save). A backup of 'settings.json' may be exported via Save As by changing the file name and/or choosing another folder. For example, 'myfolder\2017-01-01_vsc_user_settings.json'. To use the backup file, open it in VSC and copy/paste the code back into Preferences/User or Preferences/Workplace 'settings.json'.

https://code.visualstudio.com/docs/customization/userandworkspace

Turn off PHP validation: settings.json

// Place your settings in this file to overwrite default and user settings.
{
"php.validate.enable": false
}

Use comma separators to overwrite multiple default settings: settings.json.

// Place your settings in this file to overwrite default and user settings.
{
"php.validate.enable": false,
"files.trimTrailingWhitespace": true,
"editor.autoClosingBrackets": false,
"editor.wordWrap": true
}

How do I enable PHP extensions in VS code?

There are many PHP language extensions available on the VS Code Marketplace and more are being created. You can search for PHP extensions from within VS Code in the Extensions view (Ctrl+Shift+X) then filter the extensions dropdown list by typing 'php'.

How do I get PHP code to work in Visual Studio?

There is a much easier way to run PHP, no configuration needed:.
Install the Code Runner Extension..
Open the PHP code file in Text Editor. use shortcut Ctrl+Alt+N. or press F1 and then select/type Run Code , or right click the Text Editor and then click Run Code in editor context menu..

How run PHP code in xampp with VS code?

Follow this step-by-step to create your PHP program:.
Open the directory where XAMPP is installed. ... .
Open the XAMPP folder and locate a folder named “htdocs” in it..
Inside that “htdocs” folder, create a folder and name it anything suiting your project. ... .
Now open Visual Studio Code and click on “open folder”..