Show
1) Download and Install XAMPPYou can find the XAMPP installer on the following permalink: 2) Create a new project/folderGo to the xampp\htdocs folder and create a new folder (with your project name) 3) Create a PHP file inside the project folderOpen vs code in the project folder and create a new PHP file with a .php extension (i.e FileName.php) with the following code 4) Open XAMPP Control Panel and start Apache server.5) Open the browser and search localhost/FolderName/FileName.phpCongratulations you have successfully created and run your first PHP code using visual studio code🎉. You can also check my youtube video “how to run PHP in Visual Studio Code in 2021” if any doubt.👇 OverviewAccording to a 2019 Survey from StackOverflow, Microsoft’s Visual Studio Code is the most popular Code Editor for Developers. It can be installed for free on Windows, Mac, and Linux and includes built-in support for PHP with features such as syntax highlighting and IntelliSense (code completion). Several widely used plugins are recommended here for development with PHP. https://code.visualstudio.com/ PHP Server ExtensionWhen you install PHP on your computer you can then use the PHP Server extension with VS Code to launch a site. It works perfectly with FastSitePHP, simply right-click on the [index.php] file and select [PHP Server: Serve Project] or click on the PHP Server icon in the upper-right corner of the screen. https://marketplace.visualstudio.com/items?itemName=brapifra.phpserver You will then see FastSitePHP launch (or the starter site) in your default browser. Code Runner Extensionhttps://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner With Code Runner you can run PHP files, JavaScript files, Python files or scripts from over 30 other languages. Simply right-click on the file and select [Run Code] or click the [Run] button in the upper-right corner of the screen. Console output will be displayed in the pane below your code. It’s much easier to copy content from here than a terminal or command prompt and you don’t have to switch back and forth between a terminal window for running scripts. Additional ExtensionsFind more here: https://code.visualstudio.com/docs/languages/php Updating Syntax Color for easier to read PHP tags in PHP templatesBy default PHP tags This can be easily changed in
the settings. Search for
Can I run PHP in Visual Studio Code?Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense (code completion), and snippets out of the box and you can add more functionality through community-created VS Code extensions.
How can I run PHP file in Visual Studio Code without xampp?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 do I run PHP code?You just follow the steps to run PHP program using command line.. Open terminal or command line window.. Goto the specified folder or directory where php files are present.. Then we can run php code using the following command: php file_name.php.. How set PHP executable path in VS Code?Everytime that I open VSCode I get this message: Cannot validate since no PHP executable is set. Use the setting 'php.. Go To System Properties.. Go To Advanced Tab.. Click "Environment Variables". Select Path.. Add a new path that points to your php 7 executable:. |