Full-stack SPA flow

Design once. Hydrate everywhere with PhpSPA.

Craft dynamic PHP-driven interfaces while letting Vite compile your components, Tailwind style them, and PhpSPA orchestrate seamless transitions, state hydration, and CSRF-safe requests.

Instant reload
Vite dev + PhpSPA
State sharing
Stores & Hooks
Secure forms
Built-in CSRF

Component props

<?php
class Person {
   public function __construct(
      public readonly string $name,
      public readonly string $role
   ) {}
}

function Profile(Person $person) {
   return <<<HTML
      <article>
         <h3>{$person->name}</h3>
         <p>{$person->role}</p>
      </article>
   ​HTML;
}

$p = new Person('Dave', 'Admin'); fmt($p);

return <<<HTML
   <Profile person="{$p}" />
​HTML;

PHP state hooks

<?php
use function Component\useState;
use function Component\useEffect;

$counter = useState('counter', 0);

useEffect(function () use ($counter) {
   $counter($counter() + 1);
}, [ $counter ]);

Component Router

Nested layouts & target slots

Compose layouts with multiple target areas, lazy load pages, and stream updates without rebuilding your PHP routes.

  • • Route patterns with typed params
  • • Error + loading fallbacks baked in
  • • Automatic title + metadata sync

State & Events

Share state across PHP & JS

Tap into the PhpSPA store bridge to sync props, emit lifecycle events, and respond to transitions on both sides of the stack.

  • • useState()/useEffect() helpers shared in PHP components
  • • phpspa.on('beforeload'|'load') for runtime events
  • • Session + setState bridge keeps view data alive

HTTP Bridge

Secure requests without reloads

Make CSRF-safe form posts, stream JSON payloads, and tap into PhpSPA's request middleware without touching Axios.

  • • Built-in Request + Response helpers
  • • Automatic compression + caching
  • • Fine-grained auth guards per route

Workflow

Stretch PhpSPA across the entire experience

Every step is powered by PhpSPA primitives. You write PHP structures, drop in Component targets, and let the runtime orchestrate hydration.

01 · Blueprint layouts

Slot content into named targets, define modals, fallback loaders, and page metadata directly in PHP.

02 · Bind stores

Bind useState hooks to client setState calls, subscribe to route events, and hydrate components without extra glue code.

03 · Navigate instantly

Use Component.Link or JS navigation helpers for view swaps, preserve scroll, and animate transitions per route.

04 · Ship confidently

Vite handles bundling, PhpSPA optimizes responses, and your PHP controllers remain lean.

Telemetry

Production-ready signals

Instrumentation hooks let you observe route swaps, latency, and payload sizes without bolt-on tooling.

Average swap
68 ms
Library size
277kb
Hydration score
99%

Quote

“PhpSPA bridges the comfort of PHP routing with the speed of SPA transitions. Paired with Vite and Tailwind, we iterate on real UI in minutes. The runtime events, state maps, and request helpers mean zero glue code.”

– Studio Atlas Engineering

Call to action

Drop PhpSPA into your next PHP project.

Use the CLI to scaffold routes, configure Vite for dev + prod, and keep your favorite framework (Laravel, Symfony, CodeIgniter) in the loop.

The PhpSPA starter template showcases how a PHP controller-driven site can feel like a modern SPA. The hero section explains the full-stack flow—design in Tailwind, compile with Vite, hydrate via PhpSPA, keep CSRF-safe requests, and navigate through Component.Link while state is synchronized with typed hooks. Feature decks describe the component router for nested layouts, state and event bridges, and HTTP helpers that compress payloads and enforce auth guards.Workflow panels walk through blueprinting layouts, binding stores, navigating instantly, and shipping confidently with Vite builds plus PhpSPA response optimizations. Insights highlight telemetry stats such as 68 ms swaps, 277 KB bundles, and a 99% hydration score, paired with testimonials underscoring how runtime events and request helpers eliminate glue code. The call to action reiterates that teams can scaffold routes, integrate Laravel or Symfony controllers, and install @dconco/phpspa from npm while keeping the entire stack in PHP.Together these sections summarize every capability promoted on the homepage—hero value proposition, component router features, store/Event hooks, HTTP bridge, workflow timeline, observability metrics, client quotes, and onboarding CTA—so crawlers and accessibility tools understand the full PhpSPA design system story even when visual components are hidden.