Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
alcalyn committed Apr 24, 2018
2 parents c0437e6 + 333dcf9 commit 2a837e6
Show file tree
Hide file tree
Showing 57 changed files with 138 additions and 2,800 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/tests export-ignore
/doc export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
Expand All @@ -9,3 +8,4 @@
/Makefile export-ignore
/docker export-ignore
/docker-compose.yml export-ignore
/sandstone-documentation.png export-ignore
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
matrix:
include:
- env: MODE=php
php: 5.5
php: 5.6
- env: MODE=php
php: 7.1
- env: MODE=docker
Expand Down
33 changes: 3 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The project is open for contributors pull requests or issues.

Sandstone requires:

- PHP 5.5+ or PHP 7
- PHP 5.6+ or PHP 7
- ZeroMQ
- php-zmq PHP extension

Expand Down Expand Up @@ -51,38 +51,11 @@ make

- `src/` Source code
- `tests/` Unit tests and functionnal tests with PHPUnit
- `doc/` Documentation with Jekyll
- `docker/` Docker configuration for Sandstone development (running tests)


## Documentation

This is a jekyll project.
Documentation source code is at <https://github.com/eole-io/sandstone-doc>.

Pages are at the root folder, written in markdown (`doc/*.md`).

There is also full examples pages in `doc/examples/`.

### Preview documentation locally

There is a docker environment to preview documentation locally.

Just go to `doc/`, then run make.

Then go to [http://localhost:4000/sandstone/](http://localhost:4000/sandstone/) (don't forget trailing slash).

See more about documentation's documentation in the readme:

[Documentation Readme](https://github.com/eole-io/sandstone/tree/dev/doc).

### Publishing

You need write access to publish.

Run:

``` bash
make publish
```

It'll ask for a third party access token.
See [documentation contributing](https://github.com/eole-io/sandstone-doc/blob/master/CONTRIBUTING.md) page.
120 changes: 114 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,132 @@
[![License](https://poser.pugx.org/eole/sandstone/license)](https://packagist.org/packages/eole/sandstone)


Sandstone extends Silex to easily mount a RestApi working together with a **Websocket server**.
PHP microframework designed to build a RestApi
working together with a **websocket server**.

Build a real time RestApi!

### :speech_balloon: New (18 April 2018)

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

:speech_balloon: https://framateam.org/sandstone :speech_balloon:


## Install

``` bash
composer require eole/sandstone
```


## Usage

### Create a Sandstone application

Sandstone is a Silex application with websockets:

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

### Declare a websocket topic

Just as easy as declaring a silex route:

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

return new ChatTopic($topicPattern, $channelName);
});
```

See [ChatTopic class here](https://eole-io.github.io/sandstone-doc/examples/multichannel-chat).


### 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:

``` php
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
$app->forwardEventToPushServer('article.created');
```

Then on the websocket stack:

``` php
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)
{
$this->broadcast([
'message' => 'An article has just been published: '.$event->title,
]);
}
}
```


## Examples

Working examples from scratch:

- [RestApi + Websocket + push notification](https://eole-io.github.io/sandstone-doc/examples/full)
- [Authentication on RestApi and Websockets](https://eole-io.github.io/sandstone-doc/authentication)
- [Chat example](https://eole-io.github.io/sandstone-doc/examples/multichannel-chat)


## Documentation

[See the documentation here](https://eole-io.github.io/sandstone/)
[See the full documentation here](https://eole-io.github.io/sandstone-doc/)

[![Sandstone documentation](sandstone-documentation.png)](https://eole-io.github.io/sandstone/)
[![Sandstone documentation](sandstone-documentation.png)](https://eole-io.github.io/sandstone-doc/)


## Sandstone edition

If you plan to start a new real-time Rest Api application based on Sandstone,
you may be interested by 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...

Check it out: [eole/sandstone-edition](https://github.com/eole-io/sandstone-edition).
[Get started with Sandstone edition](https://eole-io.github.io/sandstone-doc/edition/get-started).


## Misc

Articles about Sandstone:

- [Sandstone explained to NodeJS, Python or PHP users](https://alcalyn.github.io/sandstone-explained-nodejs-python-php-users/)
- [Creating a poker planning application with PHP and websockets](https://alcalyn.github.io/poker-planning-php-websockets/)
- [What is Sandstone, What can I do with Sandstone](https://alcalyn.github.io/projects/sandstone/)

Big picture: https://eole-io.github.io/sandstone-doc/big-picture


## Changelog
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"react/zmq": "0.2.*|0.3.*",
"cboden/ratchet": "0.4.*",
"league/oauth2-server": "6.*",
"symfony/event-dispatcher": "~3.0",
"symfony/security": "~2.8|~3.0",
"symfony/yaml": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/http-foundation": "~2.8|~3.0",
"symfony/routing": "~2.8|~3.0",
"symfony/event-dispatcher": "~3.0|~4.0",
"symfony/security": "~2.8|~3.0|~4.0",
"symfony/yaml": "~2.8|~3.0|~4.0",
"symfony/http-kernel": "~2.8|~3.0|~4.0",
"symfony/http-foundation": "~2.8|~3.0|~4.0",
"symfony/routing": "~2.8|~3.0|~4.0",
"alcalyn/authorization-header-fix": "~1.0.0",
"jms/serializer": "^1.4",
"alcalyn/serializer-doctrine-proxies": "~1.1.0",
Expand Down
7 changes: 0 additions & 7 deletions doc/.gitignore

This file was deleted.

29 changes: 0 additions & 29 deletions doc/Gemfile

This file was deleted.

13 changes: 0 additions & 13 deletions doc/Makefile

This file was deleted.

69 changes: 0 additions & 69 deletions doc/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions doc/_config.yml

This file was deleted.

3 changes: 0 additions & 3 deletions doc/_includes/arrow-up.html

This file was deleted.

10 changes: 0 additions & 10 deletions doc/_includes/examples/full/composer.json

This file was deleted.

7 changes: 0 additions & 7 deletions doc/_includes/examples/full/curl.log

This file was deleted.

Loading

0 comments on commit 2a837e6

Please sign in to comment.