Search by

pushinbr / pam-socket

DavidWilliamBalbino

Expressive socket API for Pam WebSockets.

Package info

github.com/push-in/pam-socket

Homepage

Issues

pkg:composer/pushinbr/pam-socket

Statistics

Installs: 61

Dependents: 1

Suggesters: 1

Stars: 0

v1.1.0 2026-08-22 02:42 UTC

README

pam-socket: Rooms, broadcasts, acknowledgements and scale-out over native WebSockets.

Rooms, broadcasts, acknowledgements, and scale-out over native WebSockets.
An event-oriented API over PAM's RFC 6455 transport with authentication, bounded events, rooms, resume behavior, and Redis Streams/NATS adapters.

Packagist PHP 8.5 License

Install · Quick example · API · Docs · Issues

Install

Create a realtime application with the --socket flag:

pam init realtime-api --template http --socket
cd realtime-api
pam dev

For Laravel, use pam init realtime-laravel --template laravel --socket. In an existing project, use pam composer require pushinbr/pam-socket. Run pam doctor after dependency changes and before creating a release.

Quick example

<?php

declare(strict_types=1);

use Pam\App;
use Pam\Http\Request;
use Pam\Http\Response;

$app = new App;

$socket = \Pam\Socket\Server::create();
$socket->on('connection', static function (\Pam\WS\Socket $client): void {
    $client->emit('welcome', ['message' => 'Connected to Pam Socket']);
});

$app->get('/api/ping', static fn (Request $request, Response $response): Response => $response->json([
    'message' => 'pong',
]));
$app->listen((int) (getenv('PAM_PORT') ?: 3000));

What you can build

  • Chat, presence, and collaboration
  • Realtime dashboards and notifications
  • Multi-worker broadcasts coordinated through Redis Streams or NATS
Role Realtime framework
Execution path PAM WebSocket transport · PHP event API
This repository owns Application events, rooms, acknowledgements, and broadcast adapters
Boundary Not wire-compatible with Socket.IO or Engine.IO clients

API guide

Surface Use it for
Server::create() Create the event layer over PAM's native WebSocket server.
on() Handle connection and application events.
auth() Authenticate the connection before application events are accepted.
emit() Broadcast an event to connected clients.
to() Target a room through a RoomEmitter.
adapter() Coordinate broadcasts across workers through supported Redis Streams or NATS adapters.

PAM Socket uses standard RFC 6455 frames and its own event envelope. It is not an Engine.IO or Socket.IO server. Clients must implement the documented PAM event contract, acknowledgement identifiers, reconnect policy, and resume behavior.

Production checklist

  • Keep request data and mutable state scoped to the current request.
  • Test success, validation failure, exception, cancellation, and timeout paths.
  • Configure explicit limits and avoid unbounded payloads, queues, or retained collections.
  • Run pam doctor, pam test, and the relevant integration suite before release.
  • Validate real dependencies and workload behavior; compatibility is not inferred from package installation alone.

Troubleshooting

  • Class not found: run pam composer install, verify PSR-4 configuration, and rerun pam doctor.
  • Behavior differs over the network: reproduce with PAM's transport integration tests; in-memory execution does not model the socket boundary.
  • A dependency blocks a worker: use PAM-native I/O, a compatible event loop, a process pool, or additional isolated workers.

Report security vulnerabilities through GitHub private vulnerability reporting or the PAM security policy, not a public issue.

Docs

Part of the PAM ecosystem

PAM

PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.

PAM PAM Desktop PAM Native Ecosystem
the runtime and CLI native desktop apps in PHP native Android and iOS apps in PHP every official package and plugin

Docs: push-in.github.io/pam-docs · Issues

Apache License 2.0: use, modify and distribute for any purpose, including commercially · Made in Brazil by Pushin