In this video we will install Visual Studio Code, install the PHP
IntelliSense extension and create a simple PHP file in Visual Studio Code. The video starts with showing you how to download and install Visual Studio Code. The second part is about how to install the PHP IntelliSense in Visual Studio Code. And, finally, we create a folder in XAMPP localhost and create a simple test example index.php file. This video is made for those looking to install Visual Studio Code, install PHP IntelliSense and/or if you are looking to find how to
create and load a simple PHP file in Visual Studio Code. If you have any question or comment, leave in the comment section below. We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. VS code is a tool mostly used by front-end developers. It’s highly optimized to work with JavaScript and TypeScript, featuring smart autocompletion, auto-imports, refactors, and other goodies. Although no match to IDEs like PHPStorm, Visual Studio Code can be customized to have better support when working PHP. The most important thing to do if you want to work with PHP in VS code is to disable the default language
server and install PHP Intelephense. This is literally 90% of the job and it’s super easy. Note: I'm not being payed by intelephense to write this! You will want to disable the default PHP suggestions integrated into VS code. To acheive this, add this line to your user settings: (To open your settings, open the console with Cmd+Shift+P and search
the key “Preferences: Open user settings (JSON)”) After changing this, your PHP code will start behaving a little big “smarter”. If you’re done this, you have it. 90% of the functions you wanted from PHPStorm are already in VS code. Here are some of those features you now have:
Some other extensions you might want to installHere are some other extensions that might be handy to cover that missing 10% of features that are not bundled with Intelephense.
Extensions for speficic tasksThere are a lot of extensions to add some little extra functionalities you might need. Like this extension to add getter and setter methods, and this one or this one to generate constructor properties. Third party integrationsIntegrations with Docker and various SQL database flavours are also available as plug-ins. A personal favourite is GitLens, that complements the Git support of the editor with some cool, advanced functions (at the expense of a little performance loss). ConclusionThere are a lot more extensions in the market and a million more posts that curate them, so I will leave this one kinda open and just drop a link to the VS code marketplace for you to take a look 😉. VS code is not an IDE, but a code editor. Yet, by using extensions we can make it look and behave kind of like an IDE. It’s no match against PHPStorm in it’s advanced features, but it can provide the most used features with some simple customizations. Have you heard about the Visual Studio Code for the Web? It's the code editor running in your browser, allowing to work with your local files, files on your GitHub repositories, or files on Azure. Anywhere. In case of the PHP language, the VS Code for the Web is perfect for quick edits on small projects, due to its limitations, PHP Tools for Visual Studio Code is now available on the VS Code for the Web. All the editor features can be used in this browser-based development environment. InstallationThere are currently a few VSCode on the Web applications, including https://vscode.dev or https://github.dev. Navigate to the one of those, and your on-line workspace will open.You can either open a folder, a remote codespace, or single files. To enable PHP support in your Open a PHP file to start working. To confirm you have successfully activated the extension, see the VSCode's Output Window, FeaturesThere is a lot of features
included; the entire code editor, IntelliSense, code formatting, errors analysis, type analysis, PHPDoc generator, multilingual PHP manual, navigating to phar files, navigating to symbols in PHP manual, outlining, code actions, signature help, auto-importing IntelliSenseThe code completion including tool tips and all the available symbol information is included. Code ActionsThe editor provides also code actions - generating constructors, implementing interface methods, getters and setters, sorting PHPDoc GeneratorPHPDoc is generated seamlessly. Just type Upon enabling the Problems AnalysisThe code editor also analyses the entire workspace for errors. The code is checked in the same way as in
Visual Studio or Visual Studio Code. Based on syntax, semantics, and the type analysis, you get code underlined, errors listed in LimitationsThe limitations are described at the VS Code's documentation page: https://code.visualstudio.com/docs/editor/vscode-web#_limitations. Since the editor won't process all the files in your workspace, the IntelliSense might not be complete. In the result, code lenses with useful commands are not enabled since they would not provide complete results, code problems do not mention unknown classes and functions, tooltips might not provide the complete information, and Laravel facades might not provide complete IntelliSense either. Additionally, the extension is unable to debug PHP code even though, it would be technically possible. Test Explorer and PHPUnit integration is not included either. It's important to remember, that the first time the extension is used, it might take a few seconds while the browser is downloading the extension file. It may be about 10 MB or more of data. How do I add IntelliSense code to Visual Studio?You can trigger IntelliSense in any editor window by typing Ctrl+Space or by typing a trigger character (such as the dot character (.) in JavaScript). Tip: The suggestions widget supports CamelCase filtering, meaning you can type the letters which are upper cased in a method name to limit the suggestions.
How do I add php code to Visual Studio?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 show IntelliSense in Visual Studio?The suggestion list of Basic completion appears when you press the default Visual Studio IntelliSense shortcut Ctrl+Space . If necessary, you can always return to the Visual Studio's native's IntelliSense. To do so, select Visual Studio on the Environment | IntelliSense | General page of ReSharper options ( Alt+R, O ).
How do I Preview php code in Visual Studio?Click the button Open In Browser on StatusBar.. In the editor, right click on the file and click in context menu Open PHP/HTML/JS In Browser.. Use keybindings Shift + F6 to open more faster (can be changed in menu File -> Preferences -> Keyboard Shortcuts ). |