- What Laravel versions does bookeenweb/opds-parser support?
- The package is PHP-based and should work with Laravel 5.8+ or later, but it lacks modern PHP features like type hints or PSR-12 compliance. Test thoroughly with your Laravel version, especially if using PHP 8.x, as the last release was in 2018. For PHP 8 compatibility, you may need to fork or wrap the library.
- How do I parse an OPDS feed from a remote URL in Laravel?
- Use the `parseURL` method of `OpdsParserBusiness`. Instantiate the parser in a service or controller, then call `$parser->parseURL('https://example.com/catalog.atom')`. For Laravel, consider wrapping this in a facade or service class to handle errors (e.g., network timeouts) and integrate with Laravel’s HTTP client like Guzzle.
- Does this package support OPDS 2.0 feeds?
- No, this package only supports OPDS 1.0/Atom feeds. If you need OPDS 2.0 parsing, you’ll need an alternative library or a custom solution. Verify the OPDS version of your target feeds before using this package, as it may not handle newer standards like JSON-based OPDS 2.0.
- Can I use this package to extract search endpoints from OpenSearch description documents?
- Yes, the `parseSearchUrl` method is designed for parsing OpenSearch description documents (e.g., `application/opensearchdescription+xml`) and extracting search endpoints. This is useful for building search functionality in your Laravel app by linking to OPDS provider search APIs.
- How should I handle malformed XML or network errors when parsing OPDS feeds?
- The package relies on PHP’s DOMDocument and SimpleXML, which may throw warnings or fail silently for malformed XML. Wrap calls in try-catch blocks and validate responses. For network errors, use Laravel’s HTTP client (e.g., Guzzle) with timeouts and retry logic. Log errors for debugging and consider adding input sanitization to mitigate XXE risks.
- Is there a Laravel-specific wrapper or service provider for this package?
- No, the package is a standalone utility with no Laravel-specific features. You’ll need to manually instantiate `OpdsParserBusiness` or create a facade/service provider to integrate it with Laravel’s dependency injection. Example: Register the parser as a singleton in a service provider or use a facade for cleaner syntax.
- What are the performance implications of parsing large OPDS feeds with this library?
- This library uses DOM parsing, which loads the entire XML into memory. For large feeds, this could be inefficient or cause memory issues. If you’re dealing with massive catalogs, consider streaming alternatives (e.g., SAX parsing) or caching parsed results. Test with sample feeds to assess performance before scaling.
- Are there alternatives to bookeenweb/opds-parser for OPDS parsing in Laravel?
- If you need modern OPDS support (e.g., OPDS 2.0, JSON), consider alternatives like custom PHP libraries using SimpleXML or libraries like `spatie/array-to-xml` for output transformations. For RESTful APIs, some OPDS providers offer JSON endpoints, which you could parse with Laravel’s built-in JSON tools or packages like `spatie/array-to-object`.
- How do I test this package in a Laravel application?
- Start by parsing a known OPDS feed (e.g., Feedbooks) in a Laravel tinker script or unit test. Validate the output structure (e.g., extracted book titles, links) against your requirements. Mock HTTP requests for remote URLs to avoid network dependencies. Use PHPUnit to test edge cases like empty feeds or malformed XML.
- Can I cache parsed OPDS feeds to improve performance in production?
- Yes, caching is recommended for production. Store parsed feeds in Laravel’s cache (e.g., Redis or file cache) with a TTL based on feed update frequency. Use the `Cache` facade to wrap parser calls, e.g., `Cache::remember('opds_feed_books', now()->addHours(1), fn() => $parser->parseURL($feedUrl))`. This reduces parsing overhead and network requests.