- How do I install this package in a Laravel project?
- Run `composer require mike42/escpos-php` in your project directory. No additional Laravel-specific setup is required, though you’ll need to configure printer connectors (e.g., network, USB) in your `config/printer.php` file.
- Which Laravel versions does escpos-php support?
- The package itself is PHP 7.4+ compatible, but Laravel integration depends on your setup. Tested with Laravel 8+ and 9+; ensure your PHP version matches Laravel’s requirements. No Laravel-specific dependencies exist.
- Can I use this for async printing in Laravel?
- Yes. Wrap print operations in a Laravel job (e.g., `PrintReceiptJob`) and dispatch them to a queue. This prevents blocking HTTP requests and handles high-volume printing efficiently.
- How do I handle printer connection failures in production?
- Use Laravel’s retry helper or queue dead-letter handling for failed jobs. For critical failures, implement a fallback (e.g., digital receipt via email) by catching exceptions in your job’s `handle()` method.
- Does this support Epson, Star, or other thermal printer brands?
- Yes. The library abstracts ESC/POS protocols, so it works with most thermal printers. Use vendor-specific `CapabilityProfile` settings (e.g., `simple`, `epson`, `star`) to handle quirks like barcode formatting or paper cuts.
- How can I test receipt formatting without a physical printer?
- Use the `FilePrintConnector` to save receipts as PDFs or text files for testing. Mock printer connectors in unit tests by extending `PrintConnector` and overriding methods like `send()` to return dummy responses.
- What are the system requirements for USB/serial printing on Linux?
- Ensure your Linux system has `php-serial` or `php-usb` extensions installed (depending on your printer interface). For USB, check permissions for `/dev/tty*` devices. Use `chmod` or `udev` rules if needed.
- Can I integrate this with Laravel Notifications for hybrid receipts?
- Yes. Extend Laravel’s `Notification` class to trigger both a physical receipt (via escpos-php) and a digital notification (e.g., email/SMS). Use the `via()` method to include `PrintChannel` alongside `MailChannel`.
- How do I configure multiple printers for different store locations?
- Bind printer connectors dynamically in your `PrinterServiceProvider` using Laravel’s IoC container. Store location-specific configs in the database or cache, then resolve the correct connector at runtime (e.g., `app()->make(NetworkPrintConnector::class, ['ip' => $location->printer_ip])).
- Are there alternatives to escpos-php for Laravel receipt printing?
- Other options include `php-escpos` (pure PHP, no Laravel integration) or vendor-specific SDKs (e.g., Star’s `StarIO`). However, escpos-php stands out for its Laravel-friendly design, queue support, and cross-platform compatibility.