PHPackages                             starfederation/datastar-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. starfederation/datastar-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

starfederation/datastar-php
===========================

A PHP SDK for working with Datastar.

1.0.0-RC.5(5mo ago)4220.6k—9.7%1[1 PRs](https://github.com/starfederation/datastar-php/pulls)7mitPHPPHP &gt;=8.1CI passing

Since Nov 24Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/starfederation/datastar-php)[ Packagist](https://packagist.org/packages/starfederation/datastar-php)[ RSS](/packages/starfederation-datastar-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (28)Used By (7)

[![Stable Version](https://camo.githubusercontent.com/cc9afa2e9b6e2fe83adecc624d6b5ec865dab02aad2695bb9654bea50c526c43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374617266656465726174696f6e2f64617461737461722d7068703f6c6162656c3d737461626c65)](https://camo.githubusercontent.com/cc9afa2e9b6e2fe83adecc624d6b5ec865dab02aad2695bb9654bea50c526c43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374617266656465726174696f6e2f64617461737461722d7068703f6c6162656c3d737461626c65)[![Total Downloads](https://camo.githubusercontent.com/a308b0d26053d844a9d2b0cd4dda62094badde86b25e49f1c47cd45872a55cf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7374617266656465726174696f6e2f64617461737461722d706870)](https://packagist.org/packages/starfederation/datastar-php)

[![](https://camo.githubusercontent.com/0463423256b1e3d458414955ddbb6efd921b5ed49e9aa3b4fc8df555e271cd82/68747470733a2f2f646174612d737461722e6465762f7374617469632f696d616765732f726f636b65742d353132783531322e706e67)](https://camo.githubusercontent.com/0463423256b1e3d458414955ddbb6efd921b5ed49e9aa3b4fc8df555e271cd82/68747470733a2f2f646174612d737461722e6465762f7374617469632f696d616765732f726f636b65742d353132783531322e706e67)

Datastar PHP SDK
================

[](#datastar-php-sdk)

This package provides a PHP SDK for working with [Datastar](https://data-star.dev/).

License
-------

[](#license)

This package is licensed for free under the MIT License.

Requirements
------------

[](#requirements)

This package requires PHP 8.1 or later.

Installation
------------

[](#installation)

Install using composer.

```
composer require starfederation/datastar-php
```

Usage
-----

[](#usage)

```
use starfederation\datastar\ServerSentEventGenerator;

// Reads signals from the request.
$signals = ServerSentEventGenerator::readSignals();
```

```
use starfederation\datastar\enums\EventType;
use starfederation\datastar\enums\ElementPatchMode;
use starfederation\datastar\ServerSentEventGenerator;

// Creates a new `ServerSentEventGenerator` instance.
$sse = new ServerSentEventGenerator();

// Sends the response headers.
// If your framework has its own way of sending response headers, manually send the headers returned by `ServerSentEventGenerator::headers()` instead.
$sse->sendHeaders();

// Patches elements into the DOM.
$sse->patchElements('', [
    'selector' => '#my-div',
    'mode' => ElementPatchMode::Append,
    'useViewTransition' => true,
]);

// Patches elements into the DOM.
$sse->removeElements('#my-div', [
    'useViewTransition' => true,
]);

// Patches signals.
$sse->patchSignals('{foo: 123}', [
    'onlyIfMissing' => true,
]);

// Executes JavaScript in the browser.
$sse->executeScript('console.log("Hello, world!")', [
    'autoRemove' => true,
    'attributes' => [
        'type' => 'application/javascript',
    ],
]);

// Redirects the browser by setting the location to the provided URI.
$sse->location('/guide');
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance73

Regular maintenance activity

Popularity39

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~40 days

Total

26

Last Release

152d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/59428c6783d02d74c8778d9953ba84c35d3877ece53f5eb393689c052a9c97e4?d=identicon)[putyourlightson](/maintainers/putyourlightson)

---

Top Contributors

[![bencroker](https://avatars.githubusercontent.com/u/57572400?v=4)](https://github.com/bencroker "bencroker (58 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (36 commits)")[![delaneyj](https://avatars.githubusercontent.com/u/438252?v=4)](https://github.com/delaneyj "delaneyj (4 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/starfederation-datastar-php/health.svg)

```
[![Health](https://phpackages.com/badges/starfederation-datastar-php/health.svg)](https://phpackages.com/packages/starfederation-datastar-php)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
