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

Portflow Laravel Package

hamzi/portflow

PortFlow connects serial hardware (thermal printers, barcode/RFID scanners, scales, IoT boards) to Laravel via a driver-based architecture. Parse raw bytes into typed events, queue routes, and printing workflows, with Web Serial API support for browser integration.

View on GitHub
Deep Wiki
Context7

Neural bridge package connecting Laravel applications with local and IoT hardware using Web Serial and clean driver abstractions.

Frequently asked questions about Portflow
How do I connect a thermal printer to Laravel using PortFlow?
Use the built-in `EscPosDriver` to send ESC/POS commands. First, register the driver in your `config/portflow.php`, then dispatch print jobs via `PortFlow::dispatch('thermal-print', ['data' => $receipt])`. The package handles raw byte conversion and queue routing automatically.
Does PortFlow support barcode scanners, and how do I parse the input?
Yes, PortFlow includes a `BarcodeLineDriver` for USB/TTY scanners. Configure it in the drivers array, then listen for `ProductScanned` events. The package parses raw input into structured DTOs (e.g., `BarcodeScanned` with `code` and `timestamp` fields) for Eloquent or queue processing.
Can I use PortFlow with Laravel 10, or is it limited to Laravel 11/12/13?
PortFlow explicitly targets Laravel 11/12/13 due to PHP 8.2+ features (enums, attributes). Laravel 10 support isn’t guaranteed, as it lacks compatibility with modern Laravel conventions like the `make:driver` Artisan command. Upgrade to Laravel 11+ for full functionality.
How do I handle Web Serial API limitations in Firefox/Safari?
PortFlow relies on the browser’s Web Serial API, which isn’t supported in Firefox/Safari. Mitigate this by either restricting your app to Chrome/Edge or implementing a Node.js serial backend as a fallback. The package provides hooks to integrate custom serial handlers.
What’s the best way to test PortFlow in a CI/CD pipeline?
Use the `portflow:test-driver` Artisan command to mock serial input/output. For hardware testing, simulate devices via virtual COM ports (e.g., `socat` on Linux) or use the `FakeSerialPort` trait in unit tests. Ensure your CI environment supports PHP 8.2+ and Laravel’s queue workers if testing async routing.
How do I create a custom driver for a non-standard protocol (e.g., Modbus)?
Run `php artisan portflow:make-driver ModbusDriver` to scaffold a driver. Override the `decodeFrame()` method to parse Modbus packets into `SerialFrame` DTOs, then register it in `config/portflow.php`. Test edge cases like malformed data or timeouts in a staging environment before production.
Can PortFlow debounce rapid hardware events (e.g., scales sending 100+ updates/sec)?
Yes, use Laravel’s queue system to route events asynchronously. Configure the `queue_connection` in `config/portflow.php` to `database` or `redis`, then set a `throttle` option in your driver. This prevents overload while preserving data integrity.
Are there security risks with direct serial port access in Laravel?
Serial ports are vulnerable to injection attacks (e.g., malicious printer commands). PortFlow includes basic validation (e.g., JSON parsing for raw-json drivers), but you must implement hardware-specific safeguards. For ESC/POS printers, whitelist allowed commands in your driver’s `validate()` method.
How does PortFlow handle state persistence for streaming data (e.g., sensor telemetry)?
The `IoTFrameBuffer` persists across requests by default, but this can cause memory leaks. Configure a TTL (e.g., `buffer_ttl` in minutes) in your driver or use `PortFlow::clearBuffer()` to manually purge stale data. Monitor buffer size in production with Laravel’s `memory` logging.
What alternatives exist if PortFlow’s Web Serial dependency is too restrictive?
For full browser compatibility, consider `node-serialport` + Laravel Echo/Pusher to relay serial data to the frontend. Alternatively, use PHP libraries like `php-serial` for backend-only serial access, though they lack Web Serial’s real-time UI features. PortFlow’s driver architecture remains reusable in these setups.
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle