- How do I install the dbp/campusonline-api package in a Laravel project?
- Run `composer require dbp/campusonline-api` in your Laravel project directory. The package has no Laravel-specific dependencies beyond PHP 8.0+ and Guzzle, which Laravel already supports via its HTTP client or GuzzleHttp\Client.
- Which Laravel versions are compatible with this package?
- The package itself doesn’t enforce Laravel version constraints, but it requires PHP 8.0+. Test thoroughly with your Laravel version (e.g., 9.x, 10.x) since it uses Guzzle under the hood, which Laravel already supports. No Laravel-specific service providers are included.
- Can I use this package with Laravel’s built-in HTTP client or Guzzle?
- Yes, the package uses Guzzle internally, which aligns with Laravel’s HttpClient facade or GuzzleHttp\Client. You can integrate it seamlessly without conflicts, though you’ll need to manually register it in your Laravel application if using service containers.
- How do I handle authentication for CAMPUSonline APIs in Laravel?
- The package supports OAuth2 (client credentials) and API tokens. For Laravel, you can integrate with Laravel Passport or Sanctum for centralized authentication. Store credentials in Laravel’s `.env` and pass them to the `Api` constructor (e.g., `new Api(base_url, client_id, client_secret)`).
- Does this package support pagination for large datasets like user lists?
- Yes, it offers both offset- and cursor-based pagination. For Laravel, you may need to normalize responses (e.g., convert cursor pagination to Laravel’s `SimplePaginator`) or fetch data in chunks to avoid memory issues with large exports.
- How do I map CAMPUSonline API responses to Laravel Eloquent models?
- The package returns raw arrays or objects (e.g., `getCardsForIdentIdObfuscated()`). Use Laravel Collections to transform responses into Eloquent models or API resources. For XML Web Services, serialize responses (e.g., `json_encode()`) before mapping.
- What are the risks of using legacy XML Web Services in this package?
- Legacy XML Web Services may be deprecated by CAMPUSonline, introducing technical debt. Evaluate whether your project should prioritize the experimental Public REST API instead. Monitor CAMPUSonline’s API documentation for deprecation notices.
- How does caching work with this package in Laravel?
- The package uses `kevinrob/guzzle-cache-middleware` (v5–v7) for caching. Configure it to avoid conflicts with Laravel’s cache (e.g., set `config('cache.default')` as the storage driver). Test caching behavior in staging to ensure performance gains.
- Is there a way to mitigate the AGPL-3.0 license impact on my Laravel app?
- The AGPL-3.0 license may require open-sourcing your entire Laravel application if modifications are made. Contact Digital Blueprint for a commercial license or assess whether your use case aligns with AGPL terms. Consult legal counsel before adoption.
- How do I handle token refreshes for OAuth2 in Laravel?
- Implement token refresh logic using Laravel Queues or cron jobs. Store refresh tokens securely (e.g., Laravel Sanctum or a dedicated database table) and use Laravel’s task scheduling to renew tokens before expiration. The package doesn’t include built-in refresh logic.