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. ✨
- Host: GitHub
- URL: https://github.com/dconco/phpspa
- Owner: dconco
- License: mit
- Created: 2025-05-30T10:37:49.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2026-01-31T21:14:13.000Z (4 months ago)
- Last Synced: 2026-01-31T21:33:57.579Z (4 months ago)
- Topics: component-library, php, phpspa, react, spa
- Language: PHP
- Homepage: https://phpspa.tech
- Size: 4.07 MB
- Stars: 59
- Watchers: 0
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: docs/security/content-security-policy.md
Awesome Lists containing this project
README

### _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://phpspa.tech)
[](https://github.com/dconco/phpspa)
[](https://packagist.org/packages/dconco/phpspa)
[](https://packagist.org/packages/dconco/phpspa)
[](https://github.com/dconco/phpspa/actions/workflows/php-tests.yml)
[](https://packagist.org/packages/dconco/phpspa)
[](https://packagist.org/packages/dconco/phpspa)
[](https://github.com/dconco/phpspa)


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