dconco / phpspa
A lightweight, component-based PHP library for building Single Page Applications (SPAs) without relying on heavy frontend frameworks.
Requires
- php: ^8.2
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.
โจ 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
anddev
via GitHub Actions (see badge above). The entrypoint istests/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
|
|
โญ If you find phpSPA useful, please give it a star!