Skip to content
/ phpspa Public

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

License

Notifications You must be signed in to change notification settings

dconco/phpspa

Repository files navigation

phpSPA - Component-Based PHP Library

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" children="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




✨ Crafted with Precision By

Dave Conco

Building modern web applications with the simplicity of PHP

GitHub Twitter Email Website


⭐ If you find phpSPA useful, please give it a star!

MIT License

About

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 3

  •  
  •  
  •