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.1(1mo ago)4133.0k↓50.9%18mitPHPPHP &gt;=8.1CI passing

Since Nov 24Pushed 1mo 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 2d ago

READMEChangelogDependencies (9)Versions (30)Used By (8)

[![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,
]);

// Removes elements from 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

57

—

FairBetter than 98% of packages

Maintenance94

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.4% 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 ~20 days

Recently: every ~77 days

Total

28

Last Release

31d 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 (61 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)
