Experience real-time communication with our comprehensive PHP SDK. Built for Laravel integration with ReactPHP and Ratchet WebSocket support.
https://connect.oddsockets.tyga.network
<?php
require_once 'vendor/autoload.php';
use OddSockets\OddSocketsClient;
// Create client instance
$client = new OddSocketsClient(
'https://connect.oddsockets.tyga.network',
'demo-api-key'
);
// Connect to server
$client->connect()->then(function() {
echo "✅ Connected to OddSockets server\n";
// Get connection stats
$stats = $client->getConnectionStats();
echo "📊 Connection established at: " .
$stats['connected_at'] . "\n";
return $client->disconnect();
})->then(function() {
echo "🔌 Disconnected successfully\n";
})->otherwise(function($error) {
echo "❌ Error: " . $error . "\n";
});
<?php
use OddSockets\OddSocketsClient;
$client = new OddSocketsClient(
'https://connect.oddsockets.tyga.network',
'demo-api-key'
);
$client->connect()->then(function() use ($client) {
echo "🔗 Joining channel 'demo-chat'\n";
return $client->joinChannel('demo-chat');
})->then(function() use ($client) {
echo "📤 Sending message to channel\n";
return $client->sendMessage('demo-chat', [
'text' => 'Hello from PHP SDK!',
'user' => 'php-demo-user',
'timestamp' => date('c')
]);
})->then(function() use ($client) {
echo "✅ Message sent successfully\n";
// Get channel stats
return $client->getChannelStats('demo-chat');
})->then(function($stats) use ($client) {
echo "📊 Channel stats retrieved\n";
return $client->leaveChannel('demo-chat');
})->then(function() {
echo "🚪 Left channel successfully\n";
});
<?php
// Laravel Controller Example
use OddSockets\Laravel\Facades\OddSockets;
class ChatController extends Controller
{
public function sendMessage(Request $request)
{
// Validate input
$request->validate([
'channel' => 'required|string',
'message' => 'required|string'
]);
// Send message via OddSockets facade
OddSockets::connect()->then(function() use ($request) {
return OddSockets::joinChannel($request->channel);
})->then(function() use ($request) {
return OddSockets::sendMessage(
$request->channel,
[
'text' => $request->message,
'user' => auth()->user()->name,
'timestamp' => now()->toISOString()
]
);
})->then(function() {
return response()->json([
'success' => true,
'message' => 'Message sent successfully'
]);
});
}
}
<?php
use OddSockets\OddSocketsClient;
$client = new OddSocketsClient(
'https://connect.oddsockets.tyga.network',
'demo-api-key'
);
$client->connect()->then(function() use ($client) {
return $client->joinChannel('lobby');
})->then(function() use ($client) {
echo "👤 Setting presence data\n";
return $client->setPresence('lobby', [
'user_id' => 'php-user-123',
'name' => 'PHP Demo User',
'status' => 'online',
'activity' => 'testing presence',
'joined_at' => date('c')
]);
})->then(function() use ($client) {
echo "✅ Presence data set\n";
echo "📊 Getting presence information\n";
return $client->getPresence('lobby');
})->then(function($presence) use ($client) {
echo "👥 Active users in lobby: " .
count($presence['users'] ?? []) . "\n";
return $client->leaveChannel('lobby');
})->then(function() {
echo "🚪 Left lobby channel\n";
});
PHP SDK Demo Ready
Ready to run demonstrations
Built with modern PHP features including strict typing, attributes, and async support.
Powered by ReactPHP and Ratchet for high-performance WebSocket connections.
Complete Laravel integration with service providers, facades, and Artisan commands.
Comprehensive error handling, logging, and monitoring capabilities.