- How do I integrate **vgrem/php-spo** with Laravel’s authentication system (e.g., Passport or Sanctum)?
- The package handles OAuth2 authentication directly, but you can integrate it with Laravel’s Passport for centralized token management. Store tokens in Laravel’s cache or database and refresh them using Passport’s built-in flows. For client credentials, manually handle token refresh logic in a Laravel service class.
- Does **vgrem/php-spo** support SharePoint on-premises (2013–2019) or only SharePoint Online?
- Yes, the package supports both SharePoint Online and on-premises deployments (2013–2019). Authentication and API calls are consistent across environments, though on-premises may require additional configuration like server-to-server auth or certificate-based flows.
- Can I use this package to sync SharePoint lists with Laravel Eloquent models?
- Absolutely. Fetch SharePoint data via the package’s fluent API, then map responses to Eloquent models using accessors/mutators or API resources. For complex nested OData structures, consider custom Eloquent relationships or Laravel’s API resource transformations.
- How do I handle rate limits or API errors (e.g., HTTP 429) in Laravel?
- Use Laravel middleware or Guzzle’s retry logic to implement exponential backoff for rate limits. For custom error handling, wrap API calls in a Laravel service class and throw exceptions that can be caught by Laravel’s exception handler or logged via Monolog.
- Is there built-in support for Microsoft Teams webhooks or real-time updates?
- No, the package doesn’t support Teams webhooks directly. For real-time updates, poll the API using Laravel queues (e.g., `queue:work`) or integrate with a third-party service like Pusher or AWS EventBridge to handle Microsoft’s change notifications.
- How do I store OAuth2 tokens securely in Laravel?
- Store tokens in Laravel’s cache (e.g., Redis) for short-lived sessions or in the database encrypted with Laravel’s encryption services. Avoid hardcoding secrets; use Laravel’s `.env` file for credentials and leverage Passport’s token repository for structured storage.
- Can I use this package with Laravel Vapor for serverless deployments?
- Yes, but ensure your Vapor setup includes Redis for token caching and rate-limiting logic. Mock Microsoft API responses during local testing with Pest or PHPUnit, and use Vapor’s queue workers for long-running operations like bulk data syncs.
- What’s the best way to handle nested OData responses in Laravel?
- Transform OData responses into Laravel-friendly formats using API resources or custom accessors/mutators. For deeply nested data, consider flattening responses in a service layer or using Laravel’s `collect()` methods to reshape arrays before passing to Eloquent.
- Are there alternatives to **vgrem/php-spo** for Microsoft 365 in PHP?
- Alternatives include the official Microsoft Graph SDK for PHP (limited to Graph API) or community packages like `microsoft/microsoft-graph`. However, **vgrem/php-spo** uniquely supports SharePoint on-premises, broader Microsoft 365 services (Teams, Outlook), and OData-specific features.
- How do I test my Laravel app’s integration with **vgrem/php-spo**?
- Use PHPUnit or Pest to mock HTTP requests to Microsoft APIs. Replace the package’s `ClientContext` with a custom mock that returns static responses. For authentication tests, verify token generation and refresh flows using Laravel’s testing helpers.