An open API service indexing awesome lists of open source software.

https://github.com/dconco/phpspa

A component-based library for building modern, reactive user interfaces in pure PHP. Inspired by React. ✨
https://github.com/dconco/phpspa

component-library php phpspa react spa

Last synced: 4 months ago
JSON representation

A component-based library for building modern, reactive user interfaces in pure PHP. Inspired by React. ✨

Awesome Lists containing this project

README

          

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](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge)](LICENSE)
[![Documentation](https://img.shields.io/badge/docs-read%20the%20docs-blue.svg?style=for-the-badge)](https://phpspa.tech)
[![GitHub stars](https://img.shields.io/github/stars/dconco/phpspa?style=for-the-badge&color=yellow)](https://github.com/dconco/phpspa)
[![PHP Version](https://img.shields.io/packagist/v/dconco/phpspa?style=for-the-badge&color=purple)](https://packagist.org/packages/dconco/phpspa)
[![Downloads](https://img.shields.io/packagist/dt/dconco/phpspa?style=for-the-badge&color=orange)](https://packagist.org/packages/dconco/phpspa)
[![PHP Tests](https://github.com/dconco/phpspa/actions/workflows/php-tests.yml/badge.svg)](https://github.com/dconco/phpspa/actions/workflows/php-tests.yml)
[![PHP Version Require](https://poser.pugx.org/dconco/phpspa/require/php)](https://packagist.org/packages/dconco/phpspa)
[![Latest Stable Version](https://poser.pugx.org/dconco/phpspa/v)](https://packagist.org/packages/dconco/phpspa)
[![Code Size](https://img.shields.io/github/languages/code-size/dconco/phpspa?label=Project%20Size)](https://github.com/dconco/phpspa)
![Lines of Code](https://raw.githubusercontent.com/dconco/phpspa/master/badge/loc.svg)
![GitHub Language Count](https://img.shields.io/github/languages/count/dconco/phpspa?label=Total%20Languages%20Used)


## ✨ **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**

```bash
composer create-project phpspa/phpspa my-phpspa-app
cd my-phpspa-app
```

**Step 3: Start Development Server**

```bash
composer start
```

🎉 **That's it!** Your PhpSPA application is now running locally.

**Open your browser and start building amazing components!**

---

### 🚀 **Quick Start**

If you want to set up PhpSPA manually, maybe in an existing project, follow these steps:

#### Install

```bash
composer require dconco/phpspa
```

#### Namespace
First you need to include the namespace at the beginning of your app.

```php
Counter: {$counter}
+

HTML;
}
```

#### Setup App

```php
$app = new App(fn() => '

');

$app->attach((new Component('HomePage'))->route('/'));
$app->run();
```

---

## ⚡ Native Compression (C++ FFI)

To enable the fastest HTML/CSS/JS compression, add this to your `php.ini`:

```ini
ffi.enable=true
extension=ffi
```

Then add this line to your code:

```php
use PhpSPA\Compression\Compressor;

$app->compression(Compressor::LEVEL_AGGRESSIVE, true)
```

You’ll see `X-PhpSPA-Compression-Engine: native` in response headers when active.

---

## 🎨 **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


PhpSPA is dependency-free, which makes it extra fast




🛡️ SEO Ready


Server-rendered for search engines


⚙️ Framework Agnostic


Works with any PHP setup

---

## 📚 **Learn More**

🔗 **[Complete Documentation](https://phpspa.tech)** — Full tutorials, examples and guides

👉 **[API References](https://phpspa.tech/references)** — Detailed API documentation for all PhpSPA features

📦 **[Packagist](https://packagist.org/packages/dconco/phpspa)** — Installation and versions

---

## 🤝 **Contributing**

We welcome contributions from the community! Whether you want to add new hooks, fix bugs, or improve documentation, your help is appreciated.

👉 **[Read our Contributing Guide](CONTRIBUTING.md)** to get started

---




## ✨ 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](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](LICENSE)