Download the PHP package mbolli/php-via without Composer
On this page you can find all versions of the php package mbolli/php-via. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mbolli/php-via
More information about mbolli/php-via
Files in mbolli/php-via
Package php-via
Short Description Real-time engine for building reactive web applications in PHP
License MIT
Informations about the package php-via
php-via
Real-time reactive web framework for PHP. Server-side reactive UIs with zero JavaScript, using OpenSwoole for async PHP, Datastar for SSE + DOM morphing, and Twig for templating.
Why php-via?
- No JavaScript to write: Datastar handles client-side reactivity, SSE, and DOM morphing
- Twig templates: familiar, powerful server-side templating
- No build step: no transpilation, no bundling, no node_modules
- Real-time by default: every page gets a live SSE connection
- Scoped state: TAB, ROUTE, SESSION, GLOBAL, and custom scopes control who shares what
- Single SSE stream: extremely efficient with Brotli compression
Requirements
- PHP 8.4+
- OpenSwoole PHP extension
- Composer
- Brotli PHP extension (optional, required for
Config::withBrotli())
Installation
Quick Start
counter.html.twig:
Core Concepts
Full documentation at via.zweiundeins.gmbh/docs
Signals: reactive state that syncs between server and client
Actions: server-side functions triggered by client events
Important: Always trigger actions with
@post()(or@patch/@put/@delete).@get()is blocked on/_action/…: GET requests return 405 Method Not Allowed, because allowing actions over GET enables top-level cross-site navigation CSRF.
Scopes: control who shares state and receives broadcasts
| Scope | Sharing | Use Case |
|---|---|---|
Scope::TAB |
Isolated per tab (default) | Personal forms, settings |
Scope::ROUTE |
All users on same route | Shared boards, multiplayer |
Scope::SESSION |
All tabs in same session | Cross-tab state |
Scope::GLOBAL |
All users everywhere | Notifications, announcements |
Custom ("room:lobby") |
All contexts in that scope | Chat rooms, game lobbies |
Views: Twig template files or inline strings
Path Parameters: auto-injected by name
Components: reusable sub-contexts with isolated state
Lifecycle Hooks
Route Groups: shared prefix and/or middleware
Broadcasting: push updates to other connected clients
Multi-node broadcasting: Redis and NATS brokers
By default php-via uses an InMemoryBroker that is correct for single-process deployments.
To fan out broadcast() calls across multiple servers or containers, swap in RedisBroker or
NatsBroker:
Both brokers reconnect automatically with exponential backoff (1 s → 30 s cap).
A GET /_health endpoint is available on every php-via server (no configuration needed):
Returns HTTP 503 when the broker is in the reconnect backoff window.
How it Works
Development
Hot PHP reload: edit a file in website/src/, the worker restarts automatically (~1 s) without dropping other connections. Twig templates are always live with no restart. See docs/development for the full workflow and how to replicate this pattern in your own project.
Credits
- Datastar: SSE + DOM morphing
- OpenSwoole: Async PHP
- Twig: Templating
- go-via/via: Original Go inspiration
License
MIT
All versions of php-via with dependencies
ext-openswoole Version *
starfederation/datastar-php Version ^1.0
twig/twig Version ^3.0
psr/http-server-middleware Version ^1.0
nyholm/psr7 Version ^1.8
openswoole/core Version ^22.2
