Back to the full WebSockets listWhat are WebSockets?


GitHubStarsLast commitProject createdClosed vsOpen issues
5 years ago
7 years ago
6 / 2


Build Status Latest Stable Version Scrutinizer Code Quality SensioLabsInsight License

PHP microframework designed to build a RestApi working together with a websocket server.

Build a real time RestApi!

💬 New (18 April 2018)

I opened a chat channel where you can get help, give feedback, and talk about Sandstone (Mattermost instance):

💬 💬


composer require eole/sandstone


Create a Sandstone application

Sandstone is a Silex application with websockets:

$app = new Eole\Sandstone\Application();

Declare a websocket topic

Just as easy as declaring a silex route:

$app->topic('chat/{channel}', function ($topicPattern, $arguments) {
    $channelName = $arguments['channel'];

    return new ChatTopic($topicPattern, $channelName);

See ChatTopic class here.

Send push notifications

When an endpoint is called on the RestApi, i.e POST /api/articles and update a resource, you can send a push notification to notify this update.

On the RestApi stack:

use Symfony\Component\HttpFoundation\Response;

$app->post('api/articles', function () use ($app) {
    // Dispatch an event on article creation
    $app['dispatcher']->dispatch('article.created', new ArticleEvent());

    return new Response([], 201);

// Send all 'article.created' events to push server

Then on the websocket stack:

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Eole\Sandstone\Websocket\Topic;

class MyWebsocketTopic extends Topic implements EventSubscriberInterface
    public static function getSubscribedEvents()
        return [
            'article.created' => 'onArticleCreated',

    public function onArticleCreated(ArticleEvent $event)
            'message' => 'An article has just been published: '.$event->title,


Working examples from scratch:


See the full documentation here

Sandstone documentation

Sandstone edition

You're planning to start a new real-time Rest Api application based on Sandstone?

You may be interested by Sandstone edition.

It already integrates a Sandstone application with a docker environment, a database, debug tools…

Get started with Sandstone edition.


Articles about Sandstone:

Big picture:


See Releases page.


This library is under MIT License.