- Can I use clue/utf8-react for Laravel WebSocket streams (e.g., Pusher, Ratchet, or Laravel Echo)?
- No, this package is not designed for Laravel. It requires a full ReactPHP event loop, which conflicts with Laravel’s synchronous HTTP kernel. For WebSocket UTF-8 handling, consider ReactPHP’s native solutions or middleware like `beberlei/ratchet` with custom stream wrappers.
- How do I install clue/utf8-react in a Laravel project?
- Run `composer require clue/utf8-react`—but integration is non-trivial. The package lacks Laravel service providers or middleware, so you’d need to manually bridge ReactPHP streams to Laravel’s Request/Response objects, which isn’t officially supported.
- Does clue/utf8-react work with Laravel Octane (ReactPHP/Swoole)?
- No, even in Octane, this package won’t integrate natively. Octane’s ReactPHP layer is for HTTP, not raw stream processing. You’d need to rewrite Laravel’s routing, sessions, and ORM to work with ReactPHP’s event loop—effectively abandoning Laravel’s core.
- Is there a simpler alternative to clue/utf8-react for UTF-8 validation in Laravel?
- Yes. For most Laravel use cases, PHP’s built-in `mbstring` functions or `symfony/polyfill-mbstring` suffice. If you’re processing streams (e.g., file uploads), use `mb_check_encoding()` or `mb_convert_encoding()` instead of a ReactPHP dependency.
- Will clue/utf8-react break my Laravel application if I install it?
- Not directly, but it’s useless without a ReactPHP server (e.g., `reactphp/http`). Installing it won’t harm Laravel, but it won’t help either—unless you’re building a separate ReactPHP microservice for stream processing, which requires significant architectural changes.
- Can I use clue/utf8-react for real-time APIs or WebSocket UTF-8 validation in Laravel?
- No. Laravel’s synchronous architecture (controllers, middleware, Eloquent) can’t coexist with ReactPHP’s event loop. For real-time APIs, use Laravel’s built-in WebSocket support (e.g., `beyondcode/laravel-websockets`) or a dedicated ReactPHP service behind a reverse proxy.
- How do I configure clue/utf8-react to replace invalid UTF-8 bytes with a custom placeholder?
- Pass the placeholder as the second argument to `new Sequencer($stream, 'X')`. For example, `$stream = new Sequencer($stdin, '⚠️')` replaces invalid bytes with a warning symbol. This works in ReactPHP contexts only—Laravel integration requires additional bridging logic.
- Are there Laravel packages that provide similar UTF-8 stream handling?
- No. Laravel’s ecosystem lacks stream-focused UTF-8 parsers because its architecture relies on synchronous I/O. For file/stream processing, use `spatie/array-to-xml` (for XML) or Laravel’s native `Storage` facade with `mbstring` validation instead of ReactPHP.
- Does clue/utf8-react support PHP 8.3, and will it ever work with Laravel?
- Yes, it supports PHP 8.3, but Laravel compatibility remains impossible. The package’s ReactPHP dependency conflicts with Laravel’s HTTP kernel. Even with PHP 8.3 features, you’d need to rewrite Laravel’s core (routing, sessions, ORM) to use ReactPHP.
- What are the risks of using clue/utf8-react in a Laravel project?
- High. Risks include blocking/non-blocking conflicts (Laravel expects synchronous I/O), resource leaks from manual stream management, and data corruption if streams are interrupted mid-processing. The package’s design assumes a ReactPHP-only environment, which Laravel cannot provide.