champs-libres/wopi-lib
Laravel-friendly PHP library to integrate WOPI (Web Application Open Platform Interface) with Office Online/Collabora. Provides helpers to implement WOPI endpoints, token handling, file access, and callbacks so you can view/edit documents from your app.
/wopi/files/{fileId}, /wopi/files/{fileId}/contents).session() helper or Illuminate\Session) can be leveraged, but the library itself does not enforce statefulness—custom logic may be needed for complex workflows (e.g., concurrent edits, access control).GET, POST, PUT, DELETE) and response formats (JSON/XML). The library abstracts these but requires:
Route::get('/wopi/files/{id}', [WopiController::class, 'getFile'])).auth:api or custom middleware) must validate WOPI AccessToken and UserId claims.Accept, Content-Type) or response codes can break Office Online integration. The library mitigates this but requires rigorous testing with real Office clients.VerifyCsrfToken middleware may need exclusion or custom logic).AccessToken (often JWT). Laravel’s Sanctum or Passport can validate tokens, but token expiration/revocation must align with WOPI’s expectations.auth:sanctum) and CORS middleware can secure WOPI endpoints.fileinfo may help with MIME type detection./wopi/files/{id} and /wopi/files/{id}/contents using the library’s WopiFile class.Response to return WOPI-compliant JSON/XML.AccessToken (e.g., decode JWT using firebase/php-jwt).Storage facade in a custom adapter for WOPI-lib (e.g., WopiStorageAdapter).Event system).GET /wopi/files/{id}) with a mock file.User model).debugbar to log WOPI-specific metrics.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| WOPI endpoint timeout | Office client shows "File not found" | Increase PHP max_execution_time, use queues. |
| Storage backend unavailable | Files inaccessible | Implement fallback storage (e.g., local cache). |
| Authentication token invalid | Unauthorized access | Rate-limit token validation, log failures. |
| Concurrent edit conflicts | Data corruption | Use optimistic locking (e.g., ETag headers). |
| Large file streaming failure | Slow performance | Tune PHP memory_limit, use chunked transfers. |
How can I help you explore Laravel packages today?