VSCode: Setting Up Live Server for PHP

Spread the love

The Live Server extension for Visual Studio Code is widely known among developers. While it’s primarily designed for static webpages like HTML, it can also handle dynamic webpages, including PHP, Node.js, and ASP.NET.

Here’s how you can set up Live Server to work with both static and dynamic webpages:

1. Install Required Extensions:

Download and install PHP Server and Live Server from the Visual Studio Code Marketplace.

2. Prepare Your PHP File

Create a PHP file, such as index.php
Place it in a sub-directory under /var/www/html/ (e.g., /var/www/html/demo/)

3. Install Live Server Chrome Extension:

VSCode Setting Up Live Server for PHP - 1

Add the Live Server Chrome extension to your browser.
Customize its settings as per your requirements.
(Attach relevant screenshots if necessary.)

4. Start Live Server in VSCode:

VSCode Setting Up Live Server for PHP - 2

Click the “Go Live” button located in the bottom-right corner of the Visual Studio Code interface.
(Attach a screenshot for clarity.)

5. Open Your PHP File in VSCode:

VSCode Setting Up Live Server for PHP - 3

Open the index.php file in Visual Studio Code.
Right-click on the file, then:Select ‘PHP Server: Reload Server’.
Choose ‘PHP Server: Open file in browser’.
(Include a context menu screenshot for better understanding.)

6. Access Your Webpage:

VSCode Setting Up Live Server for PHP - 4

Open your browser and navigate to http://localhost:3000/demo/index.php.

You can now use Live Server seamlessly for both static and dynamic websites!

Pawan Mall

Leave a Reply

Back to top