protendai/nativephp-mobile-ocr
Architecture fit: Strong fit for Laravel + NativePHP mobile applications. The package follows Laravel conventions (facade, events, service-provider-style integration implied by facade/event tests) and adds a JavaScript layer with TypeScript types for Inertia + Vue/React frontends. This reduces the need for teams to write platform-specific camera/OCR bridge code.
Integration feasibility: Feasible for teams already using NativePHP. The JS recognize(), capture(), scan(), event listeners, and rows() helper provide a clear frontend integration path. FakeBridge macros improve testability in Laravel test suites. Manifest changes (NSCameraUsageDescription, Android min 21, iOS 13.0) reduce app-side native configuration.
Technical risk: Medium. The most important migration risk is the iOS coordinate change: boxes are now pixels of the upright image (top-left origin) instead of 0-1 fractions. Code using Layout::rows() / Layout::valueBeside() is insulated, but raw fraction consumers must divide by width / height. Downscaling to 4096 px means boxes refer to the downscaled image, not necessarily the original asset; any UI overlay on an original-resolution image must account for scale. Single concurrent capture() / scan() introduces RecognitionFailed::BUSY UX handling. Cache-file cleanup means $path must be copied to permanent storage if retained.
Key questions:
width / height guaranteed non-null for all v1.0.0 native code paths, and how should null values from older native code be handled in coordinate mapping?resources/android/src/ and resources/ios/Sources/ intended for app-level customization, or should teams avoid modifying them?Stack fit: Best suited to Laravel applications using NativePHP for mobile deployment. The JS library fits Inertia + Vue/React apps and provides a typed frontend API. On-device recognition avoids server-side OCR infrastructure and keeps image processing local.
Migration path: For teams upgrading from pre-1.0 usage, audit all consumers of raw iOS boxes and convert fractions to pixels using width / height, or refactor to Layout::rows() / Layout::valueBeside(). Update iOS error handling where ScanCancelled was used for denied/restricted camera access; expect RecognitionFailed with isPermissionDenied(). Add BUSY handling for concurrent capture/scan attempts. Copy $path into permanent storage immediately if images must outlive the next capture/scan. Confirm Android gallery expectations because capture() no longer inserts into MediaStore.
Compatibility: Requires Android min 21 and iOS min 13.0. The release notes indicate backward compatibility for existing handlers because width / height are optional, but coordinate consumers are still affected by the unit change. Teams with custom native patches must reapply them because native sources moved to resources/android/src/ and resources/ios/Sources/.
Sequencing:
scan() or capture() on one platform, event handling, and rows() rendering.width / height.Maintenance: MIT licensing and included changelog reduce legal/process friction. Tests for facade, events, FakeBridge, JavaScript library, and manifest/native consistency are a positive signal. Native mobile code still raises the maintenance bar compared with pure PHP packages; teams must track NativePHP and OS compatibility.
Support: Expect support burden around camera permissions, Android 8/9 behavior, iOS permission differences, and coordinate mapping. The new isPermissionDenied() / isBusy() helpers improve diagnosability. Full-screen iOS camera/scanner presentation reduces orphaned sessions. Boost guidelines covering capture(), scan(), events, and layout helpers help onboarding.
Scaling: Recognition is device-bound, so server scaling is not the primary concern. Large photos are downscaled to 4096 px longest side, which reduces OOM risk but may affect OCR accuracy for small text. Only one capture() / scan() can be open at a time, which simplifies lifecycle management but requires UI-level serialization. Cache cleanup and temporary-file deletion keep storage bounded.
Failure modes: Permission denied, BUSY, user cancellation, recognition failure, OOM-retry behavior, temp-file deletion, and coordinate mismatch are the main failure modes. Android capture no longer writes to MediaStore, so products expecting gallery insertion must adapt. Images left by earlier requests are removed on later capture/scan, so workflows must copy $path promptly. Null width / height from older native code is a compatibility edge case for overlays.
Ramp-up: Moderate. Laravel developers can adopt the facade/events quickly; frontend developers need the JS/TypeScript integration; mobile testing is required for permissions, camera lifecycle, and high-resolution images. Teams without NativePHP experience should budget for device-level QA and native troubleshooting.
How can I help you explore Laravel packages today?