- Can I use clue/utf8-react in a standard Laravel application for handling UTF-8 strings?
- No, this package is designed for ReactPHP’s event-driven architecture, which conflicts with Laravel’s synchronous request-response model. Laravel’s HTTP kernel and middleware assume blocking I/O, making direct integration impossible without a full ReactPHP rewrite.
- What Laravel alternatives exist for UTF-8 validation and sanitization?
- For Laravel, use PHP’s built-in `mbstring` functions or packages like `symfony/polyfill-mbstring` for UTF-8 validation. Laravel’s native string handling (e.g., `Str::of()`) already supports multibyte characters without requiring async libraries.
- Is clue/utf8-react compatible with Laravel Octane (Swoole/ReactPHP)?
- Even in Octane, this package won’t integrate seamlessly with Laravel’s request lifecycle. It’s designed for standalone ReactPHP streams (e.g., WebSocket servers), not Laravel’s HTTP routing or Eloquent. You’d need a custom ReactPHP service alongside Laravel, which is non-trivial.
- How do I validate UTF-8 strings in Laravel without async libraries?
- Use PHP’s `mb_check_encoding()` or Laravel’s `Str::of()->isValidUtf8()` (if using a helper package). For sanitization, `iconv()` or `mb_convert_encoding()` with fallback handling works in synchronous contexts. No async overhead is needed for most Laravel use cases.
- What’s the performance impact of clue/utf8-react vs. native PHP UTF-8 functions?
- This package is optimized for async streams, but its lightweight API adds minimal overhead. Native `mbstring` functions are faster for synchronous Laravel tasks. Benchmark only if you’re processing *massive* UTF-8 streams in a ReactPHP app—not typical Laravel workflows.
- Can I use this package for real-time WebSocket UTF-8 handling in Laravel?
- Only if you replace Laravel’s HTTP layer entirely with ReactPHP (e.g., `reactphp/http`). This requires rewriting routing, sessions, and database logic to work with ReactPHP’s event loop, which is impractical for most Laravel projects. Consider a microservice architecture instead.
- Does clue/utf8-react support Laravel’s request/response lifecycle?
- Absolutely not. Laravel’s `Request` and `Response` objects are synchronous and block until completion, while this package processes streams asynchronously. You’d need to manually bridge data between Laravel and ReactPHP, which is error-prone and unsupported.
- What are the risks of mixing ReactPHP and Laravel in production?
- High. ReactPHP’s non-blocking model can break Laravel’s assumptions (e.g., blocking database calls, synchronous middleware). Race conditions, resource leaks, and subtle bugs are likely. Even in Octane, this creates a fragmented architecture with no clear maintenance path.
- How do I install clue/utf8-react in a Laravel project?
- You can’t install it directly for Laravel use. Run `composer require clue/utf8-react` in your project, but it won’t integrate with Laravel’s core. You’d need to build a separate ReactPHP service (e.g., for WebSockets) and communicate with Laravel via APIs or IPC.
- Is there official support or documentation for Laravel integration?
- No. The package is ReactPHP-focused with no Laravel-specific guides. The maintainer (Clue) hasn’t documented hybrid Laravel-ReactPHP setups, and the community is small. Expect to rely on sparse ReactPHP resources or build custom solutions from scratch.