Revision: The example below uses PHP 8 syntax and requires no framework or database.

Is PHP frontend or backend?

PHP is a server-side language in this setup. It can read a request, load records, apply permissions and produce an HTML response. The browser interprets that HTML, applies CSS and runs any client-side JavaScript. PHP does not directly handle a click or change the browser's document after the response has arrived.

Calling a page “a PHP frontend” usually means its interface is generated by PHP templates. A server-rendered product listing, account page or search result is still a frontend that people use. Its presentation combines server-generated HTML with browser behaviour. The PHP introductory tutorial demonstrates this approach.

Follow one request from browser to screen

  1. The browser requests a URL. A normal link or form submission can do this without JavaScript.
  2. The server runs PHP. Application code reads inputs and prepares the response. Database queries and permission checks, when needed, belong here.
  3. PHP outputs HTML. A template places prepared values into headings, links, lists and form fields.
  4. The browser renders the response. CSS controls layout. JavaScript can then handle interactions, including requesting more data from PHP endpoints.

Without an additional browser request, editing a field cannot rerun server-side PHP. A regular form reloads the page; JavaScript can request an update and change part of the page instead. Neither approach automatically makes the application faster: measure the actual interaction and network work.

A small PHP page you can run

Save this as index.php in an otherwise empty directory. It displays a greeting and accepts a name through a GET form. It only reads the request: there is no account, storage, email or database write.

<?php
declare(strict_types=1);

header('Content-Type: text/html; charset=UTF-8');

$rawName = $_GET['name'] ?? '';
$name = is_string($rawName) ? trim($rawName) : '';
$greetingName = $name === '' ? 'reader' : $name;

function escapeHtml(string $value): string
{
    return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>PHP greeting example</title>
</head>
<body>
    <h1>Hello, <?= escapeHtml($greetingName) ?>!</h1>
    <form method="get" action="/index.php">
        <label for="name">Name</label>
        <input id="name" name="name" value="<?= escapeHtml($name) ?>">
        <button type="submit">Update greeting</button>
    </form>
</body>
</html>

With PHP 8 installed, run php -S 127.0.0.1:8000 from that directory, then open http://127.0.0.1:8000/index.php. Keep this local: PHP's built-in web server is a development tool. Opening the file directly from your disk will not execute its PHP.

The first visit displays Hello, reader! Submit Ada & Lin and the greeting becomes Hello, Ada & Lin!. The input retains the submitted name. View the response source: it contains the generated heading and form, rather than the PHP function or variables.

A blank or whitespace-only name falls back to “reader”. The string check also handles a query such as ?name[]=Ada, which PHP parses as an array. This is a small example of treating request data as input to check, rather than assuming its type.

Why escape the value twice?

The name appears in two HTML locations: heading text and a quoted input value. Each output passes through htmlspecialchars. ENT_QUOTES includes both quote characters, and ENT_SUBSTITUTE replaces invalid encoding sequences. The page and escape function both specify UTF-8.

Try a name containing <b>Ada</b>: the tags should appear as text, rather than making the name bold. Escaping for these HTML locations is not a general-purpose defence for SQL, JavaScript or URLs. Each output context needs the appropriate handling. The GET value is visible in the URL, so this demonstration is unsuitable for passwords or private information.

Choose how much frontend machinery you need

For a Laravel project, choose around the hardest user interaction, the team's existing skills and who consumes the backend. These are practical starting points, rather than limits on what each approach can build.

Four ways to build a PHP-backed interface
ApproachA useful starting point forWhat to evaluate
Blade with selective JavaScriptContent pages, directories and conventional forms.Whether full-page navigation is acceptable; add small interactions where they help.
Blade and LivewirePHP-led teams building filters, editable tables and forms.Loading states, request frequency and behaviour on slow connections.
Inertia with Vue or ReactRich application screens within one Laravel application.JavaScript skills, component state and the asset build pipeline.
Separate frontend and PHP APIProducts needing independently released clients or a shared mobile/web API.Authentication, API contracts, compatibility and additional deployment ownership.

Blade: render HTML with Laravel

Blade is Laravel's template engine. A controller can prepare data and pass it to a view; the template focuses on presentation. Its escaped output syntax, such as {{ $name }}, is appropriate for ordinary text values in HTML. Unescaped output needs deliberate handling of trusted or sanitised content. See the Blade documentation for the distinction.

For a company website or a straightforward customer portal, start here if it meets the requirements. A small JavaScript enhancement for a menu or character counter does not require moving every page into a JavaScript application.

Livewire: PHP components with browser coordination

Livewire lets you describe much of an interactive interface in PHP and Blade. Its browser-side JavaScript communicates with the server and updates the interface. PHP still executes on the server; it has not become a browser language. The Livewire hydration documentation explains how component state is reconstructed across requests.

Prototype the busy screen first. A filterable order table is a useful trial: check typing, pagination, validation errors and pending requests under realistic latency. This gives a better decision than comparing framework labels.

Inertia or an API: two different arrangements

Inertia connects server-side routes and controllers to JavaScript page components. Its page visits exchange component information and data, without requiring a separately designed REST API for that interface. This is still a coordinated application; the Inertia request flow explains the boundary.

A separate frontend instead consumes an explicit API. That can be useful when web and mobile clients share a backend or teams need independent releases. It also creates decisions about authentication, errors, response formats and backwards compatibility. Do not choose that separation solely because a page contains interactive elements. Laravel's frontend overview describes the available integration paths.

Check the interface, not just the generated markup

Before shipping, test the behaviours that matter to the person using the page:

  • Labels, keyboard navigation and readable errors work at narrow viewport widths.
  • Empty, unexpected and specially formatted inputs produce a deliberate result.
  • Server-side validation and permissions still apply if browser checks are bypassed.
  • Loading, retry and duplicate-submission behaviour suit the interaction.
  • Published content appears in the response when server rendering is part of the design.

The example demonstrates output rendering, not a complete account or payment form. Adding stored changes introduces further requirements, including authorization and CSRF protection. Keep those requirements explicit when expanding it.

For an existing product, bring one representative screen and its workflow to the architecture discussion. Our Laravel and PHP development service covers selecting an approach that fits the application, including work on an existing codebase.