Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
laravel-echo
Advanced tools
Laravel Echo is a JavaScript library that makes it easy to work with WebSockets in a Laravel application. It provides a simple API for subscribing to channels and listening for events broadcast by your Laravel application.
Subscribing to Channels
This feature allows you to subscribe to a public channel and listen for events. In this example, the client subscribes to the 'orders' channel and listens for the 'OrderShipped' event.
Echo.channel('orders').listen('OrderShipped', (e) => { console.log(e.order); });
Private Channels
This feature allows you to subscribe to private channels that require authentication. In this example, the client subscribes to a private 'orders' channel specific to a user and listens for the 'OrderShipped' event.
Echo.private('orders.' + userId).listen('OrderShipped', (e) => { console.log(e.order); });
Presence Channels
Presence channels build on the concept of private channels and allow you to track the presence of users in a channel. In this example, the client joins a 'chat' room and logs the users currently in the room, as well as users joining and leaving.
Echo.join('chat.' + roomId).here((users) => { console.log(users); }).joining((user) => { console.log(user.name); }).leaving((user) => { console.log(user.name); });
Notifications
This feature allows you to listen for notifications sent to a user. In this example, the client subscribes to a private channel for a specific user and listens for notifications.
Echo.private('App.User.' + userId).notification((notification) => { console.log(notification.type); });
Socket.IO is a JavaScript library for real-time web applications. It enables real-time, bidirectional and event-based communication. Compared to Laravel Echo, Socket.IO is more general-purpose and can be used with any backend, not just Laravel.
Pusher is a hosted service that makes it super-easy to add real-time data and functionality to web and mobile applications. The pusher-js library is the client-side component. Compared to Laravel Echo, Pusher provides a hosted solution and can be used with various backend technologies.
Ably is a platform that provides APIs to simplify and overcome the complex aspects of building and maintaining a real-time messaging system. The Ably JavaScript library is the client-side component. Compared to Laravel Echo, Ably offers a more comprehensive set of features and can be used with various backend technologies.
In many modern web applications, WebSockets are used to implement realtime, live-updating user interfaces. When some data is updated on the server, a message is typically sent over a WebSocket connection to be handled by the client. This provides a more robust, efficient alternative to continually polling your application for changes.
To assist you in building these types of applications, Laravel makes it easy to "broadcast" your events over a WebSocket connection. Broadcasting your Laravel events allows you to share the same event names between your server-side code and your client-side JavaScript application.
Laravel Echo is a JavaScript library that makes it painless to subscribe to channels and listen for events broadcast by Laravel. You may install Echo via the NPM package manager.
Documentation for Echo can be found on the Laravel website.
Thank you for considering contributing to Echo! The contribution guide can be found in the Laravel documentation.
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
Please review our security policy on how to report security vulnerabilities.
Laravel Echo is open-sourced software licensed under the MIT license.
v1.17.0 - 2024-11-12
FAQs
Laravel Echo library for beautiful Pusher and Socket.IO integration
The npm package laravel-echo receives a total of 131,355 weekly downloads. As such, laravel-echo popularity was classified as popular.
We found that laravel-echo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.