Download the PHP package moonshine/twirl without Composer
On this page you can find all versions of the php package moonshine/twirl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download moonshine/twirl
More information about moonshine/twirl
Files in moonshine/twirl
Package twirl
Short Description Web sockets for MoonShine for component reload
License MIT
Homepage https://moonshine.cutcode.dev
Informations about the package twirl
Twirl - WebSocket component for MoonShine
Twirl is a lightweight, free component for integrating WebSocket updates into the MoonShine admin panel. It allows you to quickly implement real-time dynamic updates of interface elements using Centrifugo or other WebSocket servers.
Twirl features:
- Simple HTML component updates on events
- Easy integration with MoonShine and Centrifugo
- Minimal dependencies, maximum speed to launch
Twirl is ideal for basic scenarios of dynamic interface updates. For advanced features—notifications, collaborative form editing, fragment updates, and integration with various WebSocket providers—use the full Rush package.
Requirements
- MoonShine 3.0+
Install
Publish the resources and configuration:
Quick start
Add Twirl component in your MoonShineLayout or page:
Now you can trigger the event and update your component:
Twirl is a thin wrapper around updating HTML elements and a convenient interface to plug into any WebSocket transport. It does not run or configure WebSocket connections for you.
You need make the bridge between Twirl and your WebSocket stack by yourself:
- Backend: implement and bind your own broadcaster via
TwirlBroadcastContractfor any provider (Centrifugo, Pusher, Socket.IO, custom, etc.). - Frontend: subscribe to your channels with your client and pass incoming payloads to
onTwirlso Twirl can apply HTML updates.
Quick checklist:
- Implement
TwirlBroadcastContractfor your transport. - Bind it in the container.
- On the frontend, set up subscriptions and forward publications to
onTwirl()callback.
Example for Centrifugo
[!CAUTION] All examples are insecure and serve only for development
Install library for work with Centrifugo:
Up the Centrifugo instance and make some configs in your app (host, api-key, jwt-secret...).
Then implement TwirlBroadcastContract with connection to Centrifugo:
Add into provider:
Write frontend logic for connect Centrifugo with Twirl. First, install the package:
Example:
CentrifugoController example:
Centrifugo config example: