dconco/phpspa

A lightweight, component-based PHP library for building Single Page Applications (SPAs) without relying on heavy frontend frameworks.

v1.1.4 2025-07-02 13:23 UTC

This package is auto-updated.

Last update: 2025-08-19 16:51:18 UTC


README

๐Ÿงฉ phpSPA

Component-Based PHP Library for Modern Web Applications

Build dynamic, interactive web applications using reusable PHP components with state management and SPA-like behavior โ€” no JavaScript frameworks required.


License Version Documentation GitHub stars PHP Version Downloads PHP Tests


โœจ Key Features

๐Ÿงฉ Components
Reusable & Modular
Build once, use everywhere
๐Ÿง  State
Reactive Updates
Auto-sync state changes
โšก Performance
Zero Full Reloads
SPA-like experience
๐ŸŽฏ Simple
Minimal Setup
Works out of the box

๐Ÿš€ Getting Started

๐ŸŽฏ Ready to Jump In? Start with our Template!

Get up and running in 30 seconds with a complete phpSPA example

๐Ÿ“ฆ Clone Template
Pre-configured project structure
โšก Instant Setup
Dependencies + server ready

Step 1: Clone the Template

git clone https://github.com/mrepol742/phpspa-example my-phpspa-app
cd my-phpspa-app

Step 2: Install Dependencies

composer install

Step 3: Start Development Server

composer start

๐ŸŽ‰ That's it! Your phpSPA application is now running locally.

Open your browser and start building amazing components!

๐Ÿš€ Quick Start

Install

composer require dconco/phpspa

Create Component

function HomePage() {
    $counter = createState("count", 0);
    return <<<HTML
        <h1>Counter: {$counter}</h1>
        <button onclick="phpspa.setState('count', {$counter} + 1)">+</button>
        <Component.Link to="/about" label="About" />
    HTML;
}

Setup App

$app = new App('layout');
$app->targetId('app');
$app->attach((new Component('HomePage'))->route('/'));
$app->run();

๐Ÿงช Testing

  • Run locally:
composer install
composer test
  • CI: Tests run on push/PR to main and dev via GitHub Actions (see badge above). The entrypoint is tests/Test.php which runs the semicolon/ASI suite and a simple compression check.

๐ŸŽจ What You Get

๐Ÿงฑ Component Architecture
Clean, reusable PHP components
๐Ÿ”„ Reactive State
Auto-updating UI with simple state management
๐ŸŒ SPA Navigation
Smooth page transitions without reloads
๐Ÿชถ Lightweight
Just one small JavaScript file
๐Ÿ›ก๏ธ SEO Ready
Server-rendered for search engines
โš™๏ธ Framework Agnostic
Works with any PHP setup

๐Ÿ“š Learn More

๐Ÿ”— Complete Documentation โ€” Full tutorials, examples, and API reference

๐Ÿ‘‰ GitHub Repository โ€” Source code and issues

๐Ÿ“ฆ Packagist โ€” Installation and versions

๐Ÿ‘จโ€๐Ÿ’ป Created by Dave Conco

Building modern web applications with the simplicity of PHP

GitHub Twitter

โญ If you find phpSPA useful, please give it a star!

MIT License