Skip to content
Projets

À propos

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

Développement web et applicatif

Comment ces chiffres sont mesurés

What you can do

  • 🧩 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

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original
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 Documentation GitHub stars PHP Version Downloads PHP Tests PHP Version Require Latest Stable Version Code Size Lines of Code GitHub Language Count


✨ 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

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

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

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

Install

composer require dconco/phpspa

Namespace

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

<?php

use PhpSPA\App;
use PhpSPA\Component;
use function Component\useState;

require_once 'vendor/autoload.php';

Create Component

function HomePage() {
	$counter = useState("count", 0);

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

Setup App

$app = new App(fn() => '<div id="app"></div>');

$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:

ffi.enable=true
extension=ffi

Then add this line to your code:

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 — Full tutorials, examples and guides

👉 API References — Detailed API documentation for all PhpSPA features

📦 Packagist — 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 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

Explorer des projets similaires

Chargement…