I'm running a headless Drupal+Angular application where I want to run a server with some clients using WebSockets (and Ratchet). I managed to make a server script detached from Drupal sending messages to multiple Angular apps. Now I want to implement the server to Drupal in order to update an entity and pass the updated entity to all clients.

I'm struggling with the best architecture and what is possible.

Scenario I

Implement the server in a Drupal module in order to access the database directly to get and update the entity and then pass the entity to clients.

Scenario II

The server connects to the database directly, do custom queries and pass the entity to clients.

Scenario III

Create API's where the server can get and update the entity and pass the entity to clients.

For security reasons, I want to avoid Scenario II. Scenario I seem to be the nicest approach, but I'm unsure whether it's possible.

1 Answer 1


First, Drupal (PHP) makes a lousy websocket server (it’s completely engineered the other way around for it) with php 8 we are getting closer but that’s out of scope for drupal.

But Drupal services (with possibly a JWT or openID Connect endpoint) seems like the best path forwards.

(That would be a variant of option 3)

Not the answer you're looking for? Browse other questions tagged or ask your own question.