Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Wrench Laravel Package

chrome-php/wrench

Simple PHP WebSocket library with server and client support. Create a BasicServer, register multiple apps per path, handle incoming data via interfaces, and send responses back to clients. Install via Composer; supports PHP 7.4–8.5.

View on GitHub
Deep Wiki
Context7

A simple PHP WebSocket implementation

Frequently asked questions about Wrench
Can I use Wrench for Laravel real-time notifications without blocking the HTTP request?
Yes, Wrench is designed for non-blocking WebSocket communication using ReactPHP’s event loop. For Laravel, run it as a standalone process or embed it in your app’s bootstrapping, ensuring WebSocket connections don’t interfere with HTTP requests. Use Redis for shared state if needed.
How do I integrate Wrench with Laravel’s event system to push updates?
Wrench doesn’t natively integrate with Laravel events, so you’ll need to create a custom service provider or listener. Listen for Laravel events in your Wrench `DataHandlerInterface` or trigger WebSocket pushes manually via a queue job or event subscriber. Example: Dispatch a `WebSocketPushEvent` and handle it in your Wrench app.
What’s the easiest way to add authentication (e.g., JWT) to Wrench in Laravel?
Wrench supports basic auth via headers, but for Laravel JWT integration, manually validate tokens in your `DataHandlerInterface`’s `onOpen` or `onData` methods. Extract the JWT from the WebSocket handshake headers, decode it, and reject unauthorized connections. Use middleware-like logic in your Wrench app.
Does Wrench support Laravel’s broadcast channels (e.g., for Echo/Pusher) out of the box?
No, Wrench lacks native Laravel broadcast channel support. To use it with Laravel Echo, create a custom STOMP or raw adapter to bridge Laravel’s queue-based broadcasts to Wrench. Alternatively, manually publish events to Wrench from Laravel’s event system or queue workers.
What Laravel versions and PHP versions does Wrench officially support?
Wrench supports PHP 7.4–8.5 and is tested with Laravel 9+. For Laravel 11+, leverage PHP 8.5 features like named arguments or attributes. Always check the [GitHub repo](https://github.com/chrome-php/wrench) for updates, as Laravel-specific compatibility isn’t explicitly documented.
How do I handle WebSocket reconnections and resilience in production?
Wrench doesn’t include built-in reconnection logic, but you can implement it client-side (e.g., JavaScript libraries like `socket.io-client`). For server-side resilience, run multiple Wrench instances behind a load balancer (e.g., Nginx) and use Redis for session persistence. Monitor connection drops with Wrench’s PSR-3 logger.
Can I run Wrench alongside Laravel’s built-in HTTP server (e.g., `php artisan serve`)?
No, Wrench requires a separate process due to its event-loop architecture. Run it as a standalone CLI process (e.g., `php wrench.php`) or use a process manager like Supervisor. For development, use `php artisan serve` for HTTP and Wrench for WebSockets on different ports.
What are the alternatives to Wrench for Laravel WebSockets, and when should I choose them?
Alternatives include `pusher-php-server` (for Pusher integration) or `socket.io` (for broader client compatibility). Choose Wrench if you need a lightweight, protocol-compliant solution without Pusher’s vendor lock-in. Use `pusher-php-server` if you’re already using Pusher’s ecosystem or need Laravel broadcast support.
How do I test Wrench in a Laravel CI pipeline (e.g., GitHub Actions)?
Test Wrench by spinning up a temporary WebSocket server in your CI script using Docker or a local process. Use PHPUnit to mock connections and verify `DataHandlerInterface` logic. Example: Spin up a Wrench server in a container, then test client interactions with a PHP WebSocket client library like `react/websocket`.
Does Wrench work with Laravel’s queue system for delayed WebSocket messages?
Not natively, but you can integrate it by dispatching Laravel queue jobs to trigger WebSocket pushes. For example, dispatch a `PushToWebSocket` job when an event occurs, then process it in a queue worker that interacts with your Wrench server via HTTP or a shared Redis channel.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity