- Can I use salva/pdfjs-bundle in a Laravel application?
- No, salva/pdfjs-bundle is a Symfony2 bundle rather than a Laravel package. It relies on Symfony's DI container, bundle registration, Twig helpers, and Symfony asset handling, so it does not expose Laravel service providers, facades, config publishing, or Blade directives. Composer may install it, but the package would be functionally unused in a Laravel app. For Laravel, integrate Mozilla PDF.js directly through npm or Vite and a Blade view.
- Is salva/pdfjs-bundle still maintained?
- No. The package is explicitly marked NOT MAINTAINED and targets Symfony2-era PHP and front-end conventions. It has very low adoption, with around 3 stars and 0 dependents, so there is little community support or issue triage. Treat it as an old reference implementation, not production infrastructure.
- What does salva/pdfjs-bundle actually provide?
- It wraps Mozilla PDF.js for Symfony applications with Twig helpers, configurable viewer assets, and a simple way to embed browser-based PDF rendering. The reusable value is mostly the front-end PDF.js integration, not Symfony-specific PHP code. In Laravel, that pattern is better rebuilt with maintained PDF.js assets, Vite, and Blade.
- How do I render PDFs in Laravel without this bundle?
- Install PDF.js through npm and bundle it with Vite, then create a Blade component or view that initializes the viewer. Serve PDFs through a Laravel route or controller that enforces authentication and authorization instead of exposing files publicly. Configure the PDF.js worker path, CSP rules, and caching in your Laravel front-end build.
- Does salva/pdfjs-bundle support Laravel 10 or Laravel 11 and PHP 8?
- There is no evidence of support for modern Laravel or PHP 8. The package is Symfony2-era and assumes Symfony bundle APIs, Twig services, and old asset conventions that do not map to Laravel 10 or 11. Assume incompatibility until proven otherwise, and validate PHP constraints, Symfony constraints, and the bundled PDF.js version before any spike.
- What are the security risks of using salva/pdfjs-bundle in production?
- The main risks are an outdated PDF.js version, stale worker paths, unclear CSP behavior, and no active maintenance for rendering or security fixes. You would own any patched assets and compatibility shims. Also review document endpoint authentication, CORS, blob URL handling, and file confidentiality before exposing PDFs.
- Can I install salva/pdfjs-bundle with Composer in a Laravel project?
- Composer may install the package, but installation does not create Laravel integration. Without Symfony bundle registration, Twig services, and Symfony asset handling, the package will not provide usable routes, views, or helpers in Laravel. Do not treat Composer installability as proof of Laravel compatibility.
- What is a better alternative to salva/pdfjs-bundle for Laravel?
- A direct PDF.js integration using npm or Vite, a Blade component, and Laravel-authenticated PDF delivery is the best fit. It keeps upgrades explicit and avoids carrying an unmaintained Symfony2 wrapper. If you need extra features like annotation or search, evaluate maintained PDF.js distributions or modern JavaScript PDF viewer libraries.
- How should I handle authentication for PDF viewing in Laravel?
- Serve PDFs through a Laravel route protected by auth and authorization middleware, then stream the file from private storage. Use signed URLs or policy checks for time-limited access, and avoid exposing confidential documents on public disks. Ensure the PDF.js viewer fetches through the same authenticated origin or a properly configured CORS endpoint.
- How do I test a PDF viewer integration in Laravel?
- Feature-test the PDF delivery route for authentication, authorization, correct content type, and streaming behavior. Use a browser or end-to-end test to confirm the PDF.js worker loads and the viewer renders under your CSP. If you spike salva/pdfjs-bundle as a reference, isolate it outside production and assert that no Symfony services are required.