PHPackages                             elshiha/laravel-sockeon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. elshiha/laravel-sockeon

ActiveLibrary[HTTP &amp; Networking](/categories/http)

elshiha/laravel-sockeon
=======================

Laravel integration for Sockeon WebSocket server with artisan commands

v1.1.0(4mo ago)19MITPHPPHP &gt;=8.1

Since Dec 28Pushed 4mo agoCompare

[ Source](https://github.com/MahmoudElshiha/laravel-sockeon)[ Packagist](https://packagist.org/packages/elshiha/laravel-sockeon)[ RSS](/packages/elshiha-laravel-sockeon/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

Laravel Sockeon
===============

[](#laravel-sockeon)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5b5c296d525043485f6cf7b768a4fa2f7128e522affdd84255684c772ead98d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c73686968612f6c61726176656c2d736f636b656f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elshiha/laravel-sockeon)[![Total Downloads](https://camo.githubusercontent.com/8f450356cc783d7ba0300e2b512ff019d4e7d9b6c31e325c038ca32551d1477b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c73686968612f6c61726176656c2d736f636b656f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elshiha/laravel-sockeon)[![License](https://camo.githubusercontent.com/87e59a55c06e3a5046b3695192e2290e6cd39bfd35028c49d6d3fbdb83c953fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656c73686968612f6c61726176656c2d736f636b656f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elshiha/laravel-sockeon)

Laravel integration for [Sockeon](https://sockeon.com) WebSocket server with artisan commands for easy development and deployment.

Features
--------

[](#features)

- 🚀 **Easy Setup** - Get WebSocket server running in minutes
- 🛠️ **Artisan Commands** - Laravel-style commands for server management
- 📝 **Code Generation** - Generate WebSocket controllers with `sockeon:make`
- 📊 **Log Tailing** - Built-in log viewer with `sockeon:logs`
- ⚙️ **Configurable** - Environment-based configuration
- 🔧 **Auto-Discovery** - Zero configuration installation

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 11.x or 12.x
- Sockeon 2.0 or higher

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require elshiha/laravel-sockeon
```

The package will automatically register itself via Laravel's package auto-discovery.

### Publish Configuration

[](#publish-configuration)

Publish the configuration files:

```
php artisan vendor:publish --tag=sockeon-config
```

This creates:

- `config/sockeon.php` - Controllers and logging settings
- `config/sockeon-server.php` - Full server configuration with CORS, rate limiting, and more

### Publish Stubs (Optional)

[](#publish-stubs-optional)

```
php artisan vendor:publish --tag=sockeon-stubs
```

This allows you to customize the controller template used by `sockeon:make`.

Configuration
-------------

[](#configuration)

### Basic Configuration

[](#basic-configuration)

Add these variables to your `.env` file:

```
SOCKEON_HOST=0.0.0.0
SOCKEON_PORT=8080
SOCKEON_DEBUG=false
SOCKEON_LOG_FILE=
```

### Advanced Server Configuration

[](#advanced-server-configuration)

For advanced features like **CORS**, **rate limiting**, **authentication**, and **proxy support**, publish the configuration and edit `config/sockeon-server.php`:

```
php artisan vendor:publish --tag=sockeon-config
```

The `config/sockeon-server.php` file allows you to configure:

#### Available Options

[](#available-options)

**Basic Settings:**

- `host`, `port`, `debug` - Server fundamentals
- `queue_file` - Message persistence
- `auth_key` - Authentication key
- `health_check_path` - Health check endpoint

**CORS Configuration:**

- `allowed_origins` - Allowed origins (default: `['*']`)
- `allowed_methods` - HTTP methods
- `allowed_headers` - Allowed headers
- `allow_credentials` - Allow credentials
- `max_age` - Preflight cache duration

**Rate Limiting:**

- `enabled` - Enable/disable rate limiting
- `maxHttpRequestsPerIp` - HTTP request limit per IP
- `maxWebSocketMessagesPerClient` - WebSocket message limit
- `maxConnectionsPerIp` - Connection limit per IP
- `maxGlobalConnections` - Global connection limit
- `whitelist` - IP whitelist

**Security:**

- `trust_proxy` - Trusted proxy IPs/CIDR ranges

### Environment Variables

[](#environment-variables)

OptionDescriptionDefault`SOCKEON_HOST`WebSocket server host`0.0.0.0``SOCKEON_PORT`WebSocket server port`8080``SOCKEON_DEBUG`Enable debug mode`false``SOCKEON_LOG_FILE`Custom log file path`storage/logs/sockeon-websocket.log``SOCKEON_AUTH_KEY`Authentication key`null``SOCKEON_RATE_LIMIT_ENABLED`Enable rate limiting`false`Usage
-----

[](#usage)

### 1. Create a WebSocket Controller

[](#1-create-a-websocket-controller)

Generate a new WebSocket controller:

```
php artisan sockeon:make ChatController
```

This creates a controller at `app/WebSocket/ChatController.php`:

```
