PHPackages                             silverstripedev/silverstripe-headless - 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. [API Development](/categories/api)
4. /
5. silverstripedev/silverstripe-headless

ActiveSilverstripe-vendormodule[API Development](/categories/api)

silverstripedev/silverstripe-headless
=====================================

Silverstripe CMS headless features

020PHP

Since Apr 25Pushed 1y agoCompare

[ Source](https://github.com/silverstripeviet/silverstripe-headless)[ Packagist](https://packagist.org/packages/silverstripedev/silverstripe-headless)[ RSS](/packages/silverstripedev-silverstripe-headless/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Headless features for Silverstripe CMS
======================================

[](#headless-features-for-silverstripe-cms)

This module provides several core features for building headless websites with Silverstripe CMS. While it is used primarily in support of the [silverstripe/silverstripe-nextjs](https://github.com/silverstripe/silverstripe-nextjs) module, it is framework agnostic and could be used as a platform for any headless solution.

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

[](#installation)

This module requires the pre-release of `silverstripe/graphql` version 4. Please see the [installation instructions](https://docs.silverstripe.org/en/4/developer_guides/graphql/getting_started/) for using version 4 in a stable release of `silverstripe/recipe-cms`.

Once you have `silverstripe/graphql:^4` installed, you can add this module using a standard composer installation.

```
composer require silverstripe/silverstripe-headless

```

Features
--------

[](#features)

- Bulk loading of models into the schema, e.g. `MyApp\Models\*`
- Several helper fields added to all dataobjects (`hashID`, `typeAncestry`, `exists`, etc.)
- Webhooks (incoming and outgoing)
- Published state (awaiting publication / publish history)
- API Key authentication (see [sminnee/silverstripe-apikey](https://github.com/sminnee/silverstripe-apikey))
- All `ContentController` requests 404 (e.g. no frontend)
- Base URL redirects to `/admin`
- DataObject change tracking to provide transparency of what will be published

Getting started
---------------

[](#getting-started)

You'll first want to decide which models you want exposed to your content API. This is done with an allow list rather than an exclude list. You can wildcard namespaces to make this easier.

To include models, update the config on `SilverStripe\Headless\GraphQL\ModelLoader`. Here is the default configuration:

```
SilverStripe\Headless\GraphQL\ModelLoader:
  included_dataobjects:
    page: 'Page'
    cms: 'SilverStripe\CMS\Model\SiteTree'
    siteconfig: 'SilverStripe\SiteConfig\*'
    assets: 'SilverStripe\Assets\*'
    elemental: 'DNADesign\Elemental\Models\*'
```

Include a similar config in your project.

**app/\_config/modelLoader.yml**

```
SilverStripe\Headless\GraphQL\ModelLoader:
  included_dataobjects:
    - MyApp\Models\*
    - SomeModule\Models\SomeModel
    # etc...
```

### Need help generating this list? Use config generation tool.

[](#need-help-generating-this-list-use-config-generation-tool)

It can get quite granular deciding what models to include and which to leave out, particularly when you have a lot of modules installed. To help generate this list, use your browser and navigate to `/dev/generate-included-classes`.

[![](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/generate_classes.png)](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/generate_classes.png)

It's a crude UI, but it will provide you with checkboxes for every DataObject class in the system and generate a corresponding config for you.

### Accessing the GraphQL API

[](#accessing-the-graphql-api)

The API should be all wired up on `/graphql` with `read` and `readOne` operations for each of your exposed DataObjects. Use the GraphQL IDE supplied by [silverstripe/graphql-devtools](https://github.com/silverstripe/graphql-devtools) to browse the API and try out some queries.

Other features
--------------

[](#other-features)

### Extra dataobject fields

[](#extra-dataobject-fields)

- `hashID: String!`: A unique ID across the entire database. Based on a `ID / baseClass` tuple.
- `typeAncestry: [[String]]`: A list of all the ancestral types for this model. e.g. `[BlogPage, Page, SiteTree]`
- `exists: Boolean!`: Useful in rendering or hiding UI -- check if the model's `exists()` function returns true.

### Webhooks

[](#webhooks)

Webhooks are a key part of making a headless set up work. It's the primary way that the CMS communicates with the headless instance (e.g. Netlify, Vercel).

#### Incoming webhooks

[](#incoming-webhooks)

By default, three incoming webhooks are provided -- one for each deploy event: `DEPLOY_START | DEPLOY_FAILURE | DEPLOY_SUCCESS`.

[![](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/incoming_webhooks.png)](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/incoming_webhooks.png)

#### Outgoing webhooks

[](#outgoing-webhooks)

The most important outgoing webhook you'll want to define is a "Publish" webhook, which will be invoked when the "publish" button is clicked in the "Awaiting publication" view.

[![](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/outgoing_webhooks.png)](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/outgoing_webhooks.png)

The "publish" hook specifically has two types of behaviour associated with it:

- `OPTIMISTIC`: Mark the content published, and don't wait for confirmation from the hosting provider. If your hosting provider doesn't provide outgoing webhooks, this may be necessary, but it's not recommended, as publishes can fail for a number of reasons.
- `DEFER`: Mark the content as "pending" publication, and wait to mark it published until an incoming webhook, e.g. `DEPLOY_SUCCESS` is received. Netlify offers outgoing webhooks free for all sites. See below.

You can test a webhook by clicking "Invoke webhook". If a 200 response is received, you'll get a green status message.

##### Authenticating incoming requests (Netlify only)

[](#authenticating-incoming-requests-netlify-only)

Netlify allows you to send a JWT-signed message with its outgoing webhook calls. If you're using Netlify, it's a good idea to take advantage of this feature to minimise the exploit surface of your CMS instance.

All you need to do is define an arbitrary secret in the `NETLIFY_JWS_SECRET` environment variable (e.g. a random 64-character string), and provide this same secret to the outgoing webhook defined in Netlify. When it fires the outgoing webhook event, Silverstripe will check the signature on the request to validate authenticity.

### Publishing content

[](#publishing-content)

Publication is a manual process. A publish to the hosting provider is *not* triggered on every single publish to the *database*. The assumption is that content changes can happen rapidly and many are ephemeral (i.e. fixing typos in haste) and continuous content deployment isn't always a great fit, although this feature is inconsideration for the future.

As changes happen in the CMS, the content changes are tracked. Any changes to DataObjects that are exposed to your API will be recorded in the "Awaiting Publication" admin, where you can publish them.

[![](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/awaiting_publication.png)](https://raw.githubusercontent.com/silverstripe/silverstripe-headless/main/screeenshots/awaiting_publication.png)

Once changes are published, they get added to the "Publish history" view.

### API key authentication

[](#api-key-authentication)

All members can generate API keys. See the "Api keys" tab on the detail view of every member. Passing this key in the graphql request in the `X-API-Key` header will authenticate as the member associated with that key. This is useful for reading draft or other protected content.

Further reading
---------------

[](#further-reading)

See the [silverstripe/silverstripe-nextjs](https://github.com/silverstripe/silverstripe-nextjs) module for a more detailed implementation of the features provided by this module.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef3eb725f96c6765a1ae74ccd856452775f821464b49149870844508b191e6e9?d=identicon)[taicait](/maintainers/taicait)

---

Top Contributors

[![taicait](https://avatars.githubusercontent.com/u/648750?v=4)](https://github.com/taicait "taicait (4 commits)")

### Embed Badge

![Health badge](/badges/silverstripedev-silverstripe-headless/health.svg)

```
[![Health](https://phpackages.com/badges/silverstripedev-silverstripe-headless/health.svg)](https://phpackages.com/packages/silverstripedev-silverstripe-headless)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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