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

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

wu/giorgio-socket
=================

laravel swoole socket server

1.0.8(2y ago)36MITPHPPHP ^8.0.2

Since Nov 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/m-finder/giorgio-socket)[ Packagist](https://packagist.org/packages/wu/giorgio-socket)[ RSS](/packages/wu-giorgio-socket/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (1)Versions (11)Used By (0)

[![](https://camo.githubusercontent.com/23cbf1628d7e28b914339044d22da152e953fc1dec9dc6eeb056b2897e2e8c47/68747470733a2f2f6d2d66696e6465722e6769746875622e696f2f696d616765732f6176617461722e6a706567)](https://camo.githubusercontent.com/23cbf1628d7e28b914339044d22da152e953fc1dec9dc6eeb056b2897e2e8c47/68747470733a2f2f6d2d66696e6465722e6769746875622e696f2f696d616765732f6176617461722e6a706567)

[![](https://camo.githubusercontent.com/f8f9cee0ea67d842b33a5a9761547225012eed6bc1ba6601c1b322d4fd04249e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f417574686f722d6d2d2d66696e6465722d726564)](https://camo.githubusercontent.com/f8f9cee0ea67d842b33a5a9761547225012eed6bc1ba6601c1b322d4fd04249e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f417574686f722d6d2d2d66696e6465722d726564)[![](https://camo.githubusercontent.com/42657d7c7526c069652f3cdf79e07b5de0af62d6a4497509e16c81f8785c7fda/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e35322e302d726564)](https://camo.githubusercontent.com/42657d7c7526c069652f3cdf79e07b5de0af62d6a4497509e16c81f8785c7fda/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e35322e302d726564)[![](https://camo.githubusercontent.com/8f5eabc216bce417110082368c59866c66b3ee33f3b0eef6e4c977c5492b0285/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53776f6f6c652d352e302e332d726564)](https://camo.githubusercontent.com/8f5eabc216bce417110082368c59866c66b3ee33f3b0eef6e4c977c5492b0285/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53776f6f6c652d352e302e332d726564)[![License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](https://packagist.org/packages/wu/giorgio-socket)

About Giorgio Socket
--------------------

[](#about-giorgio-socket)

Add a socket server based on Swoole to your Laravel application.

[ 中文文档 ](https://m-finder.github.io/2023/11/20/2023-11-20-laravel-swoole-socket/)

### Preview

[](#preview)

[![](https://repository-images.githubusercontent.com/721082370/0240b5fa-69e2-4bf0-89f2-fbed407c2b54)](https://repository-images.githubusercontent.com/721082370/0240b5fa-69e2-4bf0-89f2-fbed407c2b54)

### Install

[](#install)

Require socket server

```
composer require wu/giorgio-socket

```

Publish config

```
php artisan vendor:publish --provider="GiorgioSocket\Providers\SocketServiceProvider"

```

Start socket server

```
php artisan socket:start

```

### Important Considerations

[](#important-considerations)

- You can customize your own business logic by implementing the interfaces under the folder `GiorgioSocket\Services\Handlers\Interfaces`.
- If you want to send a message from the server, there are two ways to do it:
    - First: Using HTTP client. ```
        Route::get('/socket', function () {
            \Illuminate\Support\Facades\Http::asForm()->post('http://127.0.0.1:9501', [
                'to' => 2,
                'message' => 'server message',
            ]);
        });
        ```
    - Second：Using Listener，Redis is required. and you need to modify the `QUEUE_CONNECTION` configuration in the .env file to "redis" or another asynchronous queue driver. After making the configuration change, you should run the following command: `php artisan queue:work --queue=socket-listener`, You can invoke it as shown in the following code. ```
        Route::any('socket', function (Request $request){
            \GiorgioSocket\Events\SocketEvent::dispatch($request->get('to'), $request->get('message'));
        });

        ```
- If you are using the `laravel/breeze` package and working with Blade templates, you can paste the following code into `dashboard.blade.php` for a quick test. ```
    @auth

                            messages：

                            from

                            to

                            message

          let heartBeatTimer = 0;
          let socket = connectWebSocket();

          function startHeartbeat(interval) {
            interval = interval || 30;
            heartBeatTimer = setInterval(function () {
              sendMessage(null, "heart_beat");
            }, interval * 1000);
          }

          function stopHeartbeat() {
            clearInterval(heartBeatTimer);
          }

          function connectWebSocket() {
            const wsServer = 'ws://127.0.0.1:9501';
            const socket = new WebSocket(wsServer);

            let userId = document.getElementById('from').value;
            socket.onopen = function (evt) {
              let data = {
                user_id: userId,
                type: 'connect'
              };
              console.log('open', data)
              socket.send(JSON.stringify(data));
            };

            socket.onmessage = function (evt) {
              console.log('get message from server: ' + evt.data);

              if (evt.data !== 'heart_beat') {
                let data = JSON.parse(evt.data);
                let message = document.getElementById("server-message")
                message.innerHTML += data.user_name + ': ' + data.data + ''
              }
            };

            socket.onerror = function (evt) {
              console.log(evt);
            };

            socket.onclose = function () {
              let data = {
                user_id: userId,
                type: 'close'
              };
              socket.send(JSON.stringify(data));
            };
            return socket;
          }

          function sendMessage(to, message) {
            if (socket != null && socket.readyState === WebSocket.OPEN) {
              if (message !== 'heart_beat') {
                let messageBox = document.getElementById("server-message")
                messageBox.innerHTML += 'me: ' + message + ''
              }
              let from = document.getElementById("from")
              socket.send(JSON.stringify({
                user_id: from.value,
                user_name: '{{ auth()->user()->name }}',
                to: to,
                type: 'message',
                data: message,
              }));
              console.log("webSocket send message：" + JSON.stringify({
                user_id: from.value,
                user_name: '{{ auth()->user()->name }}',
                to: to,
                type: 'message',
                data: message,
              }));
            } else {
              console.log("webSocket closed");
            }
          }

          let button = document.getElementById("submit");
          button.addEventListener('click', function () {
            let message = document.getElementById("message");
            let to = document.getElementById("to");
            sendMessage(to.value, message.value)
          });

    @endauth

    ```

### License

[](#license)

The Giorgio Socket is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~13 days

Recently: every ~26 days

Total

9

Last Release

803d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/46b1fb52820a402b267705d4a327f82cb7ea1030604f3c21029de203d9f6179e?d=identicon)[m-finder](/maintainers/m-finder)

---

Top Contributors

[![m-finder](https://avatars.githubusercontent.com/u/27805032?v=4)](https://github.com/m-finder "m-finder (32 commits)")

---

Tags

laravelsocketswoolelaravelSocketswooleim

### Embed Badge

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

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

###  Alternatives

[lomkit/laravel-rest-api

A package to build quick and robust rest api for the Laravel framework.

59152.2k](/packages/lomkit-laravel-rest-api)[denis660/laravel-centrifugo

Centrifugo broadcaster for laravel

113164.7k](/packages/denis660-laravel-centrifugo)[opekunov/laravel-centrifugo-broadcaster

Centrifugo broadcaster for Laravel 8.75-11.x and Centrifugo &gt;= 5.0

49461.3k](/packages/opekunov-laravel-centrifugo-broadcaster)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[huang-yi/shadowfax

Run Laravel on Swoole.

3511.7k](/packages/huang-yi-shadowfax)

PHPackages © 2026

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