tabuna / Web Socket
Licence: mit
Laravel library for asynchronously serving WebSockets.
Stars: ✭ 225
Projects that are alternatives of or similar to Web Socket
Mercurius
Real-time Messenger for Laravel
Stars: ✭ 309 (+37.33%)
Mutual labels: laravel, laravel-package, websockets
Laravel Surveillance
Put malicious users, IP addresses and anonymous browser fingerprints under surveillance, log the URLs they visit and block malicious ones from accessing the Laravel app.
Stars: ✭ 198 (-12%)
Mutual labels: laravel, laravel-package
Socket Controllers
Use class-based controllers to handle websocket events.
Stars: ✭ 191 (-15.11%)
Mutual labels: socket, socket-io
Voyager Frontend
The Missing Front-end for The Missing Laravel Admin 🔥
Stars: ✭ 200 (-11.11%)
Mutual labels: laravel, laravel-package
Laravel Userstamps
Laravel Userstamps provides an Eloquent trait which automatically maintains `created_by` and `updated_by` columns on your model, populated by the currently authenticated user in your application.
Stars: ✭ 193 (-14.22%)
Mutual labels: laravel, laravel-package
Laravel Option Framework
Manage your laravel application's dynamic settings in one place with various supported input types.
Stars: ✭ 194 (-13.78%)
Mutual labels: laravel, laravel-package
Voyager Hooks
Hooks system integrated into Voyager.
Stars: ✭ 200 (-11.11%)
Mutual labels: laravel, laravel-package
Vuesocial
something like QQ、weibo、weChat(vue+express+socket.io仿微博、微信的聊天社交平台)
Stars: ✭ 189 (-16%)
Mutual labels: socket, socket-io
Oksocket
An blocking socket client for Android applications.
Stars: ✭ 2,359 (+948.44%)
Mutual labels: socket, socket-io
Meter
Laravel package to find performance bottlenecks in your laravel application.
Stars: ✭ 204 (-9.33%)
Mutual labels: laravel, laravel-package
Sneaker
An easy way to send emails whenever an exception occurs on server.
Stars: ✭ 223 (-0.89%)
Mutual labels: laravel, laravel-package
Laravel Castable Data Transfer Object
Automatically cast JSON columns to rich PHP objects in Laravel using Spatie's data-transfer-object class
Stars: ✭ 191 (-15.11%)
Mutual labels: laravel, laravel-package
Laravel Localization Helpers
🎌 Artisan commands to generate and update lang files automatically
Stars: ✭ 190 (-15.56%)
Mutual labels: laravel, laravel-package
Laravel Terminator
A package to help you clean up your controllers in laravel
Stars: ✭ 217 (-3.56%)
Mutual labels: laravel, laravel-package
Laravel Bootstrap Components
Bootstrap components as Laravel components
Stars: ✭ 190 (-15.56%)
Mutual labels: laravel, laravel-package
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (-12%)
Mutual labels: laravel, laravel-package
Laravel State Machine
Winzou State Machine service provider for Laravel
Stars: ✭ 213 (-5.33%)
Mutual labels: laravel, laravel-package
Laravel Adminer
Adminer database manager for Laravel 5+
Stars: ✭ 185 (-17.78%)
Mutual labels: laravel, laravel-package
Laravel Cross Eloquent Search
Laravel package to search through multiple Eloquent models. Supports sorting, pagination, scoped queries, eager load relationships and searching through single or multiple columns.
Stars: ✭ 189 (-16%)
Mutual labels: laravel, laravel-package
Hooks
Hooks is a extension system for your Laravel application.
Stars: ✭ 202 (-10.22%)
Mutual labels: laravel, laravel-package
Warning this repository is no longer supported
https://github.com/beyondcode/laravel-websockets
If you are looking for a good way to use laravel's web socket please look:
Laravel library for asynchronously serving WebSockets.
Build up your application through simple interfaces and re-use your application without changing any of its code just by combining different components.
Installation Laravel WebSocket
install package
$ composer require orchid/socket
edit config/app.php service provider : (Laravel < 5.5)
Orchid\Socket\SocketServiceProvider::class
structure
php artisan vendor:publish
Usage
Create socket listener:
To create a new listener, you need to
php artisan make:socket MyClass
In the folder app/Http/Sockets
create template Web listener socket
After creating a need to establish a route which Is located routes/socket.php
//routing is based on an Symfony Routing Component
$socket->route('/myclass', new MyClass, ['*']);
To launch the web-socket, use the command:
php artisan socket:serve
FAQ
JavaScript
Connecting Web socket in JavaScript
var socket = new WebSocket("ws://localhost");
socket.onopen = function() {
alert("The connection is established.");
};
socket.onclose = function(event) {
if (event.wasClean) {
alert('Connection closed cleanly');
} else {
alert('Broken connections');
}
alert('Key: ' + event.code + ' cause: ' + event.reason);
};
socket.onmessage = function(event) {
alert("The data " + event.data);
};
socket.onerror = function(error) {
alert("Error " + error.message);
};
//To send data using the method socket.send(data).
//For example, the line:
socket.send("Hello");
Authorization
Example of installation numbers unique socket and session laravel
public function onOpen(ConnectionInterface $conn)
{
$this->clients->attach($conn);
//take user id
$userId = $this->getUserFromSession($conn);
//Create a list of users connected to the server
array_push($this->userList, $userId);
//We tell everything that happened
echo "New connection! user_id = ({$userId})\n";
}
public function getUserFromSession($conn)
{
// Create a new session handler for this client
$session = (new SessionManager(App::getInstance()))->driver();
// fix issue https://github.com/laravel/framework/issues/24364
if (Config::get('session.driver') == 'file') {
clearstatcache();
}
// Get the cookies
$cookies = $conn->WebSocket->request->getCookies();
// Get the laravel's one
$laravelCookie = urldecode($cookies[Config::get('session.cookie')]);
// get the user session id from it
$idSession = Crypt::decrypt($laravelCookie);
// Set the session id to the session handler
$session->setId($idSession);
// Bind the session handler to the client connection
$conn->session = $session;
$conn->session->start();
//We take the user from a session
$userId = $conn->session->get(Auth::getName());
return $userId;
}
Nginx proxy
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server you-web-site.com:5300;
}
server {
listen 443;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
}
Supervisor
[program:laravel-socket]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/your-path/artisan socket:serve
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/your-path/storage/logs/socket.log
License
The MIT License (MIT). Please see License File for more information.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].