OneCompiler
PHP

PHP

Backend

PHP runs a huge share of the web, from small sites to large applications. This workspace ships a minimal PHP web server that serves an HTML page and a JSON endpoint, so it opens in a built-in browser preview as soon as you start it.

What's included

Web server, ready to serve

public/index.php serves an HTML page and a /api/ping JSON route. Start the built-in PHP server and Studio opens it in a browser preview.

Real VS Code

The full cloud editor with an integrated terminal, the PHP extensions and an Xdebug launch config in the .vscode folder.

Git ready

Clone, commit and push from the terminal, or connect a GitHub repo whenever you're ready.

Fast cold start

Boots in about a minute, with PHP installed so the server is one command away.

Tech stack

PHPPHP built-in serverXdebugVS Code

What is PHP?

PHP is a server-side scripting language built for the web. A request comes in, PHP runs your script, and the output is sent back to the browser. It powers a large portion of the internet, including content systems and many custom web applications.

This workspace is a small PHP web project rather than a framework setup. It serves a greeting page and a JSON endpoint through PHP's built-in development server, so you have a working request loop to extend without installing anything extra.

What's inside this workspace

The app lives in public/index.php. It reads the request path, returns a JSON message for /api/ping, and otherwise renders a small HTML page that confirms the server is up. It's deliberately framework-free so you can see exactly how a request is handled.

PHP is already installed, and the .vscode folder includes an Xdebug launch config so you can step through requests. The doc root is the public folder, which keeps your entry point separate from the rest of the project.

Building and running

Open the terminal and run php -S 0.0.0.0:8000 -t public to start PHP's built-in development server with public as the document root. Studio opens the app in a built-in browser preview where you can load the page. From the terminal you can also hit the API directly, for example curl http://localhost:8000/api/ping.

You can also press F5 to launch the app in debug mode using the bundled Xdebug config, which starts the server and attaches the debugger so breakpoints fire on incoming requests.

What you can build

Small web apps, JSON APIs, form handlers, or a learning project to understand how PHP processes requests. Add more routes to index.php, install a framework like Laravel or Symfony with Composer, or wire in a database when you're ready to go further.

Frequently asked questions

How do I run the PHP app?

Open the terminal and run php -S 0.0.0.0:8000 -t public. That starts PHP's built-in server with the public folder as the document root, and Studio opens it in a browser preview. You can also press F5 to run it in debug mode.

What does the starter do?

public/index.php serves a small HTML page that confirms the server is running, and it returns a JSON message when you request /api/ping. It's a minimal, framework-free starting point you can extend.

Can I debug PHP here?

Yes. The .vscode folder ships an Xdebug launch config. Press F5 to start the server with the debugger attached, set breakpoints in your PHP files and they'll fire on incoming requests.

Can I use a framework like Laravel or Symfony?

Yes. Install Composer dependencies from the terminal and bring in whichever framework you want. The template stays out of your way so you can structure the project however suits you.

Can I test the API from the terminal?

Yes. With the server running, use curl, for example curl http://localhost:8000/api/ping, to get the JSON response without opening the browser preview.

Is it free?

PHP runs on a paid Studio plan. Templates that are free to launch are marked as such, and you can upgrade from the pricing page to use this one.

Related templates

PHP online Studio — cloud PHP web workspace | OneCompiler