- How do I integrate azure-oss/storage-common’s SAS helper into my Laravel app’s config/services.php?
- Centralize SAS settings in `.env` (e.g., `AZURE_SAS_EXPIRY_MINUTES=60`) and bind them in `config/services.php` under `config('services.azure.sas')`. Register the `AzureSasGenerator` as a singleton in your service provider, injecting the config values for expiry and permissions. This ensures a single configuration point for all Azure Storage interactions.
- Does this package support Laravel’s Filesystem adapters (e.g., storage_disk('azure')->url()) with SAS tokens?
- No, the package itself doesn’t include a built-in Filesystem adapter, but you can extend Laravel’s `FilesystemManager` to create an `azure-sas` disk that generates SAS URLs dynamically. The README excerpt suggests a custom `AzureSasFilesystem` class for this purpose, which you’d register in a service provider.
- Will this break my existing SAS token generation logic if I migrate to the shared helper?
- Only if your code relies on hardcoded expiry times or permissions. The shared helper centralizes these values via Laravel’s config, so updating your controllers/services to use `app(AzureSasGenerator::class)` will maintain compatibility. Test thoroughly, especially if you’ve overridden default SAS behavior in the past.
- Is azure-oss/storage-common compatible with Laravel 9+ and PHP 8.2+?
- Yes, the package supports Laravel 9+ and PHP 8.0+. While it uses PHP 8.0+ features like named arguments, there are no breaking changes for PHP 8.2+. However, if you’re using newer Laravel features like enums, verify compatibility in your test suite, as the package itself doesn’t enforce strict PHP 8.2+ dependencies.
- Can I customize SAS permissions (e.g., read-only vs. read-write) via Laravel config?
- Absolutely. Define `AZURE_SAS_PERMISSIONS` in your `.env` (e.g., `r` for read-only or `rwdl` for full access) and bind it to `config('services.azure.sas.permissions')`. The shared helper will use these values for all generated tokens, reducing boilerplate in your controllers or services.
- How do I test SAS token generation in Laravel’s test suite?
- Mock the `AzureSasGenerator` singleton in your tests using Laravel’s `partialMock` or `Mockery`. Verify token generation by checking expiry timestamps, permissions, and container/blob paths. The package’s modular design makes it easy to isolate tests—focus on the helper’s output rather than Azure’s actual API calls.
- Does this package introduce performance overhead for high-volume SAS token generation?
- The shared helper is optimized for minimal overhead, but test under load (e.g., 1000+ tokens/sec) in your staging environment. The centralized logic reduces duplication but adds a single dependency. If performance is critical, benchmark against your existing SAS generation code to compare latency.
- Are there alternatives to azure-oss/storage-common for Laravel Azure SAS tokens?
- Yes, you could use the official Azure SDK (`microsoft/azure-storage-blob-php`) or roll your own helper class. However, this package offers Laravel-specific benefits like config integration, singleton registration, and modularity across Azure Storage types (Blob, File Share). It’s ideal if you’re already using the Azure OSS PHP ecosystem.
- How does this package handle invalid SAS inputs (e.g., malformed expiry times)?
- The shared helper validates inputs and throws Laravel-compatible exceptions like `InvalidArgumentException` for malformed expiry times or permissions. This aligns with Laravel’s error-handling patterns, making it easier to integrate with your existing exception handling (e.g., `try-catch` blocks or global handlers).
- Can I extend the SAS helper to support Azure’s newer features (e.g., IP restrictions) without forking?
- Yes, the package’s modular design allows you to extend the `AzureSasGenerator` via interfaces or decorators. Monitor Azure’s SDK roadmap for updates, and override the helper’s methods (e.g., `generate()`) to add custom logic like IP restrictions. This approach keeps your changes maintainable alongside upstream updates.