PHPackages                             larago/socket - 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. larago/socket

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

larago/socket
=============

Real-time WebSocket Broadcasting Engine for Laravel. Go-powered server with cross-platform support (Windows, macOS, Linux). Public &amp; Private channels with JWT authentication.

v2.0.5(1mo ago)017MITHTMLPHP &gt;=7.4

Since Apr 20Pushed 1mo agoCompare

[ Source](https://github.com/M-Bilal-4720/Socket)[ Packagist](https://packagist.org/packages/larago/socket)[ Docs](https://github.com/M-Bilal-4720/Socket)[ RSS](/packages/larago-socket/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

LaraGo Socket Package
=====================

[](#larago-socket-package)

[![Latest Stable Version](https://camo.githubusercontent.com/2ad4319e6aaf1993b14781b94c58ec741f1c78278d3fe1f51d3ae6a0264bf5ff/68747470733a2f2f706f7365722e707567782e6f72672f6c617261676f2f736f636b65742f76)](https://packagist.org/packages/larago/socket)[![Total Downloads](https://camo.githubusercontent.com/a14899f68858a5fee57b407274f597561b34ae06248e15e9e1de93c47122c7b7/68747470733a2f2f706f7365722e707567782e6f72672f6c617261676f2f736f636b65742f646f776e6c6f616473)](https://packagist.org/packages/larago/socket)[![License](https://camo.githubusercontent.com/0acf6e9d3ae4c3a8ea65df0edf0caff5fdd39a75f79b32b1ae66bda3e7578b9b/68747470733a2f2f706f7365722e707567782e6f72672f6c617261676f2f736f636b65742f6c6963656e7365)](https://github.com/M-Bilal-4720/Socket/blob/master/LICENSE)[![PHP Version Require](https://camo.githubusercontent.com/4f4f42de7bca081926fcbbc0c76a0ba6a085484476c5c5a76f36e2873bdbd7dd/68747470733a2f2f706f7365722e707567782e6f72672f6c617261676f2f736f636b65742f726571756972652f706870)](https://packagist.org/packages/larago/socket)[![Laravel Support](https://camo.githubusercontent.com/8785d1dde8282cfe716f1ab9d58bec5fd97554769398543d19f43945eb85c521/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382532302537432532303925323025374325323031302532302537432532303131253230253743253230313225323025374325323031332d627269676874677265656e)](https://packagist.org/packages/larago/socket)

Real-time WebSocket Broadcasting Engine for Laravel with Go Backend

⚡ **Zero configuration** - Auto-builds Go engine on first run via Artisan command
✅ **Supports Laravel 8 - 13** - Including brand new Laravel 12 &amp; 13
🌍 **Cross-platform** - Works on Windows, macOS, and Linux with single codebase

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Features](#features)
- [How It Works](#how-it-works)
- [Platform-Specific Guides](#platform-specific-guides)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [License](#license)

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

[](#requirements)

- **PHP:** 7.4 or higher
- **Laravel:** 8.0, 9.0, 10.0, 11.0, 12.0, or 13.0+
- **Go:** 1.20+ (auto-downloaded and used, no installation needed for binary build)
- **Composer:** For package management

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

[](#installation)

### Option 1: From Packagist (Recommended)

[](#option-1-from-packagist-recommended)

```
composer require larago/socket
```

Then start the engine:

```
php artisan larago:run
```

> **Note:** The Go engine binary is automatically built on first run. No manual compilation needed!

### Option 2: From GitHub (Development)

[](#option-2-from-github-development)

```
# Add VCS repository configuration
composer config repositories.socket vcs https://github.com/M-Bilal-4720/Socket.git

# Install the package
composer require larago/socket:dev-master --prefer-source
```

Then start the engine:

```
php artisan larago:run
```

### Option 3: From Local Path (Development)

[](#option-3-from-local-path-development)

Add to your main `composer.json`:

```
"repositories": [
    { "type": "path", "url": "./packages/LaraGo" }
],
"require": {
    "larago/socket": "*"
}
```

Then run:

```
composer update
```

Start the engine:

```
php artisan larago:run
```

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

[](#configuration)

### Step 1: Configure Broadcasting Driver

[](#step-1-configure-broadcasting-driver)

In `config/broadcasting.php`, add:

```
'larago' => [
    'driver' => 'larago',
],
```

Set in `.env`:

```
BROADCAST_DRIVER=larago

```

### Step 2: Run Go Engine (Artisan Command)

[](#step-2-run-go-engine-artisan-command)

```
# Start the WebSocket engine (default)
php artisan larago:run --background

# Custom port
php artisan larago:run --port=9000 --background

# Custom host and port
php artisan larago:run --host=127.0.0.1 --port=3000 --background

# Generate JWT token for private channels
php artisan larago:token --user-id=1 --expires=3600

# Stop the engine
php artisan larago:stop
```

**The engine will automatically build the Go binary on first run if needed!**

Features
--------

[](#features)

✨ **Zero Configuration** - Auto-builds Go binary on first run
🔐 **Channel-Level Access Control:**

- Public Channels - Anyone can subscribe
- Private Channels - Require JWT authentication (prefix: `private-`)

🚀 **Highly Configurable:**

- Custom WebSocket port (`--port=8080`)
- Custom host (`--host=0.0.0.0`)
- Custom Laravel communication port (auto: 6001)

🔄 **Built-in Testing:**

- Browser-based test page at `/larago-test`
- Test both public and private channels
- Real-time message monitoring

⚡ **Background Process Management:**

- Runs as background process with `--background`
- Auto-detach process
- Process monitoring and logging

🌍 **Cross-Platform:**

- Windows 10/11+ with Go installed
- macOS 10.15+ with Go installed
- Linux (Ubuntu, Debian, CentOS, etc.)

📚 **Comprehensive Documentation:**

- Setup guides for each OS (WINDOWS\_SETUP.md, MACOS\_SETUP.md, LINUX\_SETUP.md)
- Quick fix guide for Windows (WINDOWS\_QUICK\_FIX.md)
- Channel architecture guide (CONNECTION\_MODES.md)

See [CONNECTION\_MODES.md](CONNECTION_MODES.md) for detailed channel architecture and security guide.

Usage
-----

[](#usage)

In your Laravel Event:

```
broadcast(new YourEvent($data));
```

In your frontend, connect to WebSocket:

```
const ws = new WebSocket('ws://localhost:8080/ws');
ws.onopen = () => {
    ws.send(JSON.stringify({
        event: 'subscribe',
        channel: 'your-channel'
    }));
};
ws.onmessage = (event) => {
    console.log(JSON.parse(event.data));
};
```

How It Works
------------

[](#how-it-works)

1. **Go Engine** listens on two interfaces:

    - WebSocket on port 8080 (customizable) for frontend connections
    - TCP socket on 127.0.0.1:6001 for Laravel backend communication
2. **Laravel** sends broadcast messages to Go via TCP socket
3. **Go** routes messages to WebSocket clients subscribed to the channel

Architecture
------------

[](#architecture)

```
Laravel App → TCP Socket → Go Engine → WebSocket → Frontend
            (127.0.0.1:6001)   (:8080)

┌─────────────────────────────────────────────────────────┐
│ Single WebSocket Connection Supports:                   │
│ • Public Channels (anyone can subscribe)                │
│ • Private Channels (require JWT authentication)         │
└─────────────────────────────────────────────────────────┘

```

**Benefits:**

- ✅ Cross-platform: TCP works on Windows, Mac, Linux
- ✅ No dependency on Unix-specific features
- ✅ Easier debugging and monitoring
- ✅ Better Windows support

Platform-Specific Guides
------------------------

[](#platform-specific-guides)

### Windows

[](#windows)

See [WINDOWS\_SETUP.md](WINDOWS_SETUP.md) for detailed Windows installation and troubleshooting. Quick fix: [WINDOWS\_QUICK\_FIX.md](WINDOWS_QUICK_FIX.md)

**Key Steps:**

```
# Build the engine
build.bat

# Run the engine
php artisan larago:run --background
```

### macOS

[](#macos)

See [MACOS\_SETUP.md](MACOS_SETUP.md) for detailed macOS setup.

**Key Steps:**

```
# Build the engine
bash build.sh

# Run the engine
php artisan larago:run --background
```

### Linux

[](#linux)

See [LINUX\_SETUP.md](LINUX_SETUP.md) for detailed Linux setup with Systemd configuration.

**Key Steps:**

```
# Build the engine
bash build.sh

# Run as service
sudo systemctl start larago.service
```

Testing
-------

[](#testing)

### Browser Test Page

[](#browser-test-page)

Once the engine is running, open:

```
http://localhost:8000/larago-test

```

### Test Public Channels

[](#test-public-channels)

```
const ws = new WebSocket('ws://localhost:8080/ws');
ws.send(JSON.stringify({
    event: 'subscribe',
    channel: 'public-chat'
}));
```

### Test Private Channels

[](#test-private-channels)

```
const ws = new WebSocket('ws://localhost:8080/ws');
ws.send(JSON.stringify({
    event: 'subscribe',
    channel: 'private-user-1',
    token: 'your-jwt-token-here'
}));
```

Generate token:

```
php artisan larago:token --user-id=1
```

Troubleshooting
---------------

[](#troubleshooting)

### Port Already In Use

[](#port-already-in-use)

```
# Find process on port 8080
lsof -i :8080  # macOS/Linux
netstat -ano | findstr :8080  # Windows

# Kill process or use different port
php artisan larago:run --port=9000
```

### Go Not Installed

[](#go-not-installed)

1. Download from
2. Install and verify: `go version`
3. Restart terminal and try again

### Windows Build Issues

[](#windows-build-issues)

- Run Command Prompt as Administrator
- Ensure Go is in PATH: `go version`
- Check build.bat output for specific errors

### Engine Won't Start

[](#engine-wont-start)

Check logs:

```
tail -f storage/logs/larago-engine.log  # macOS/Linux
type storage\logs\larago-engine.log     # Windows
```

### Connection Issues

[](#connection-issues)

- Verify WebSocket URL: `ws://localhost:8080/ws`
- Check if port 8080 is accessible: `curl -i http://localhost:8080/ws`
- Check Laravel communication: `php artisan larago:test-broadcast`

Channel Architecture
--------------------

[](#channel-architecture)

For detailed information about public and private channels, see [CONNECTION\_MODES.md](CONNECTION_MODES.md)

### Public Channels

[](#public-channels)

- Anyone can subscribe
- No authentication required
- Pattern: `any-channel-name`

### Private Channels

[](#private-channels)

- Require JWT token to subscribe
- Automatically identified by `private-` prefix
- Pattern: `private-user-1`, `private-room-5`, etc.

Commands Reference
------------------

[](#commands-reference)

```
# Start engine in foreground
php artisan larago:run

# Start engine in background
php artisan larago:run --background

# Use custom port
php artisan larago:run --port=9000

# Use custom host and port
php artisan larago:run --host=127.0.0.1 --port=3000

# Force kill existing engine before starting
php artisan larago:run --force

# Stop the engine gracefully
php artisan larago:stop

# Force stop the engine
php artisan larago:stop --force

# Generate JWT token
php artisan larago:token --user-id=1 --expires=3600

# Test broadcasts
php artisan larago:test-broadcast
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

The LaraGo Socket package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

50d ago

Major Versions

v1.2.0 → v2.0.02026-04-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/42513cdc6610b21a5b86db55382ef8c321614f3947ac820ba6ad49960a8c6213?d=identicon)[M-Bilal-4720](/maintainers/M-Bilal-4720)

---

Top Contributors

[![malik4573](https://avatars.githubusercontent.com/u/113805005?v=4)](https://github.com/malik4573 "malik4573 (24 commits)")[![M-Bilal-4720](https://avatars.githubusercontent.com/u/154483880?v=4)](https://github.com/M-Bilal-4720 "M-Bilal-4720 (4 commits)")

---

Tags

jwtlaravelAuthenticationserverwebsocketreal-timeSocketBroadcastingchannelgogolangprivate-channelspublic-channels

### Embed Badge

![Health badge](/badges/larago-socket/health.svg)

```
[![Health](https://phpackages.com/badges/larago-socket/health.svg)](https://phpackages.com/packages/larago-socket)
```

###  Alternatives

[denis660/laravel-centrifugo

Centrifugo broadcaster for laravel

119182.2k](/packages/denis660-laravel-centrifugo)[vinelab/minion

A Simple WAMP (Web Application Messaging Protocol) server and command line tool

1276.5k](/packages/vinelab-minion)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)[redbaron76/larapush

a Ratchet and ZMQ implementation for Laravel 4

251.0k](/packages/redbaron76-larapush)[warriorxk/phpwebsockets

A websocket library with support for IPC using socket pairs

1325.5k](/packages/warriorxk-phpwebsockets)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
