PHPackages                             baraadark/laravelsocket - 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. [API Development](/categories/api)
4. /
5. baraadark/laravelsocket

ActiveLibrary[API Development](/categories/api)

baraadark/laravelsocket
=======================

BaraaDark Laravel Socket is a powerful Laravel package that simplifies the integration of real-time WebSocket functionality into your Laravel projects. With this package, you can effortlessly create and manage a Node.js WebSocket server inside your Laravel application and utilize the Elephant.io library for seamless communication with Socket.io in PHP

050PHP

Since Apr 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Baraa-Darkazalli/LaravelSocket)[ Packagist](https://packagist.org/packages/baraadark/laravelsocket)[ RSS](/packages/baraadark-laravelsocket/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

LaravelSocket
=============

[](#laravelsocket)

BaraaDark Laravel Socket is a powerful Laravel package that simplifies the integration of real-time WebSocket functionality into your Laravel projects. With this package, you can effortlessly create and manage a Node.js WebSocket server inside your Laravel application and utilize the Elephant.io library for seamless communication with Socket.io in PHP

BaraaDark/LaravelSocket Package
===============================

[](#baraadarklaravelsocket-package)

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

[](#installation)

You can install the LaravelSocket package using Composer by running the following command:

```
composer require baraadark/laravelsocket:dev-master
```

After installation, configure the server settings by running:

```
php artisan socket:config
```

Enter the host and port for Socket event listening.

Next, initialize the Node.js server by running:

```
php artisan socket:init
```

This will set up the necessary Node.js dependencies.

Define Socket.IO Events To define Socket.IO events, you need to publish the events.php route file by running:

```
php artisan vendor:publish --tag=socket-route
```

Edit the events.php file and define your events logic as Laravel routes. Each route you define here will correspond to two Socket.IO events:

A 'fetch' event for fetching data. A 'load' event for loading data. The event names will match the route name with 'fetch/' or 'load/' prefixed to it. For example:

```
Route::get('students/index', [SocketController::class, 'index']);
```

'fetch/students/index' event for fetching data. 'load/students/index' event for loading data. Ensure that your route action returns JSON data using the response()-&gt;json() method, as this is required for Socket.IO communication. Example:

```
return response()->json([
    'data' => $your_data,
    // ... other JSON data
]);
```

Update Socket.IO Events To update your Socket.IO events based on your routes, run:

```
php artisan socket:events
```

This command will generate the necessary JavaScript code to handle the Socket.IO events.

Using LaravelSocket Facade You can use the LaravelSocket Facade object to emit events from anywhere in your code. For example, you can emit events in an observer:

```
use BaraaDark\LaravelSocket\Facades\LaravelSocket;

class StudentObserver
{
    // ...

    private function reloadData(): void
    {
        LaravelSocket::emit('students/index');
    }

    public function created(Student $student): void
    {
        self::reloadData();
    }

    // ...

    public function forceDeleted(Student $student): void
    {
        self::reloadData();
    }
}
```

You can also pass data to the emit function:

```
LaravelSocket::emit('your/route/endpoint', $yourDataAsArray);
```

This allows you to send specific data to clients when emitting events.

Feel free to customize and expand upon this package to suit your application's real-time communication needs.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4331357c7c1a9936b022f538db260bd22fd4f35d9c9027bdb288c5c08e26352d?d=identicon)[BaraaDark](/maintainers/BaraaDark)

---

Top Contributors

[![Baraa-Darkazalli](https://avatars.githubusercontent.com/u/80644482?v=4)](https://github.com/Baraa-Darkazalli "Baraa-Darkazalli (55 commits)")

### Embed Badge

![Health badge](/badges/baraadark-laravelsocket/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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