PHPackages                             shingo-kumagai/siren-module - 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. shingo-kumagai/siren-module

ActiveLibrary

shingo-kumagai/siren-module
===========================

1.x-dev(10y ago)3252[1 issues](https://github.com/kuma-guy/BEAR.SirenModule/issues)MITPHP

Since Jun 29Pushed 10y agoCompare

[ Source](https://github.com/kuma-guy/BEAR.SirenModule)[ Packagist](https://packagist.org/packages/shingo-kumagai/siren-module)[ RSS](/packages/shingo-kumagai-siren-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

BEAR.SirenModule
================

[](#bearsirenmodule)

**WARNING: This is highly experimental stuff that isn't ready for production use yet.**

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/842311b0e937c99d84994fccd6eb10189585eb48d202841e64dfd9a8439ba7b2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7368696e676f2d6b756d616761692f424541522e536972656e4d6f64756c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/shingo-kumagai/BEAR.SirenModule/?branch=master)[![Build Status](https://camo.githubusercontent.com/9cd7b28ae02f0e42bdb793f0a811e7dc7e8de6ffec6628efece3eda4d501f641/68747470733a2f2f7472617669732d63692e6f72672f7368696e676f2d6b756d616761692f424541522e536972656e4d6f64756c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/shingo-kumagai/BEAR.SirenModule)

Siren support for BEAR.Sunday

**Siren renderer**

It overrides default renderer and represents your resource in Siren format.

Siren \[\]

Demo
----

[](#demo)

Demo application using this module \[\]

Entity
------

[](#entity)

#### class (optional)

[](#class-optional)

You can specify this optional value with `@SirenClass` annotation.

```
@SirenClass("order")

```

#### properties (optional)

[](#properties-optional)

Properties are the response body of the resource object.

Entities
--------

[](#entities)

Add sub related resource entities using `@SirenEmbedResource` annotation.

```
@SirenEmbedResource(rel="customer", src="app://self/customer?customerId={customerId}")

```

And then, you can embed the entity by request like below.

```
$this['customer']->addQuery(['customerId' => $customerId])->eager->request();

```

For sub related link entity use `@SirenEmbedLink` annotation.

```
@SirenEmbedLink(rel="order-items", src="app://self/order/items?orderNumber={orderNumber}")

```

Actions
-------

[](#actions)

Action can be added using `@SirenAction` annotation.

```
@SirenAction(src="app://self/order/items?orderNumber={orderNumber}", method="post")

```

The actual method defined as `SirenAction` has to be annotated like below.

```
    /**
     * @SirenName("add-item")
     * @SirenTitle("Add Item")
     * @SirenField(name="orderNumber", type="hidden", value="{orderNumber}")
     * @SirenField(name="productCode", type="text")
     * @SirenField(name="quantity", type="number")
     *
     * @param int $customerId
     * @return $this
     */
    public function onPost($customerId)
    {
        // do something...
        return $this;
    }
```

#### name (required)

[](#name-required)

You need to define action name using `@SirenName` annotation when you want to represent `Action`

#### title (optional)

[](#title-optional)

This is optional. You can specify with `@SirenTitle` annotation.

#### field (optional)

[](#field-optional)

This is going to be controls of the action. You can add user control for the action with `@SirenField` annotation.

#### type (optional)

[](#type-optional)

WIP

Links
-----

[](#links)

```
@SirenLink(rel="previous", param="orderNumber")
@SirenLink(rel="next", param="orderNumber")

```

Example
-------

[](#example)

#### Response

[](#response)

```
{
    "class": [
        "order"
    ],
    "properties": {
        "orderNumber": 42,
        "itemCount": 3,
        "status": "pending"
    },
    "entities": [
        {
            "href": "/customer?customerId=pj123",
            "rel": [
                "customer"
            ],
            "class": [
                "info",
                "customer"
            ],
            "properties": {
                "customerId": "pj123",
                "name": "Peter Joseph"
            }
        },
        {
            "href": "/orderitems?orderNumber=42",
            "rel": [
                "order-items"
            ],
            "class": [
                "items",
                "collection"
            ]
        }
    ],
    "actions": [
        {
            "name": "add-item",
            "href": "/orderitems?orderNumber=42",
            "method": "POST",
            "title": "Add Item",
            "type": "application/x-www-form-urlencoded",
            "fields": [
                {
                    "name": "orderNumber",
                    "type": "hidden",
                    "value": "42"
                },
                {
                    "name": "productCode",
                    "type": "text"
                },
                {
                    "name": "quantity",
                    "type": "number"
                }
            ]
        }
    ],
    "links": [
        {
            "rel": [
                "self"
            ],
            "href": "/orders?orderNumber=42"
        },
        {
            "rel": [
                "previous"
            ],
            "href": "/orders?orderNumber=41"
        },
        {
            "rel": [
                "next"
            ],
            "href": "/orders?orderNumber=43"
        }
    ]
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% 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

Unknown

Total

1

Last Release

3976d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3edf42babdb017f2ec023b6cad24e3db1eacf0941bf97ea10bbd32978c3dd8be?d=identicon)[shingo-kumagai](/maintainers/shingo-kumagai)

---

Top Contributors

[![kuma-guy](https://avatars.githubusercontent.com/u/7978290?v=4)](https://github.com/kuma-guy "kuma-guy (130 commits)")[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (13 commits)")

### Embed Badge

![Health badge](/badges/shingo-kumagai-siren-module/health.svg)

```
[![Health](https://phpackages.com/badges/shingo-kumagai-siren-module/health.svg)](https://phpackages.com/packages/shingo-kumagai-siren-module)
```

###  Alternatives

[bear/package

BEAR.Sunday application framework package

30527.9k23](/packages/bear-package)[bear/sunday

A resource-oriented application framework

247584.6k21](/packages/bear-sunday)[bear/skeleton

Skeleton application for BEAR.Sunday

1315.6k1](/packages/bear-skeleton)

PHPackages © 2026

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