- How do I configure BunnyCDN as a filesystem disk in Laravel using this package?
- Add the `bunnycdn` disk to your `config/filesystems.php` under the `disks` array. Specify your BunnyCDN API key, secret, endpoint, bucket, and URL (for CDN delivery) using environment variables. Example: `'driver' => 'bunnycdn', 'key' => env('BUNNYCDN_KEY'), 'bucket' => env('BUNNYCDN_BUCKET')`. The package handles the rest, making BunnyCDN behave like a native Laravel disk.
- Does this package support Laravel’s media libraries like Spatie Media Library?
- Yes, this adapter fully integrates with Spatie Media Library and other Flysystem-compatible media packages. Configure your media library to use the `bunny` disk, and it will handle uploads, conversions, and storage seamlessly. No additional setup is required beyond defining the disk in your Laravel config.
- What Laravel versions are supported by platformcommunity/flysystem-bunnycdn?
- The package is designed for Laravel 8.x and 9.x, leveraging Flysystem v1.0+. It follows Laravel’s filesystem abstraction, so it works with any version that supports the `Storage` facade and Flysystem integration. Always check the package’s repository for the latest compatibility notes, as minor updates may align with newer Laravel releases.
- Can I use BunnyCDN for private files with this adapter?
- Yes, the adapter supports private storage workflows. BunnyCDN’s native access controls (e.g., signed URLs) can be managed via the `url()` method or by generating temporary URLs in your application logic. For public files, the CDN delivers assets globally with low latency, while private files remain secure behind BunnyCDN’s access policies.
- How do I handle errors or exceptions when using BunnyCDN with Flysystem?
- The adapter wraps BunnyCDN’s SDK responses in Flysystem exceptions, but some errors may require custom handling. For example, BunnyCDN-specific errors (like quota limits) might not map directly to Flysystem’s `FilesystemException`. Override the adapter’s `throwException()` method or use a try-catch block around `Storage::disk('bunny')->put()` to handle edge cases gracefully.
- Is this adapter suitable for high-traffic applications with frequent file uploads?
- While the adapter abstracts BunnyCDN’s storage operations, performance depends on BunnyCDN’s regional endpoints and your application’s network latency. For high-traffic apps, benchmark upload/download speeds against your BunnyCDN zone’s location. Consider using BunnyCDN’s pull zones for static assets to offload delivery from your Laravel servers.
- Can I migrate from AWS S3 to BunnyCDN using this package without rewriting code?
- Yes, the adapter maintains Flysystem’s interface, so replacing `'driver' => 's3'` with `'driver' => 'bunnycdn'` in your `filesystems.php` config is often sufficient. Test critical paths (e.g., media uploads, backups) in staging first, as BunnyCDN’s API may differ slightly from S3 in edge cases like metadata handling or error codes.
- Does this package support server-side encryption (SSE) or KMS for BunnyCDN storage?
- No, the adapter does not natively support BunnyCDN’s server-side encryption features like SSE or KMS. These must be configured directly via BunnyCDN’s API or SDK before using the adapter. Check BunnyCDN’s documentation for instructions on enabling encryption at the bucket or object level.
- How do I generate CDN URLs for files stored with this adapter?
- The adapter automatically generates CDN URLs when you specify the `url` option in your disk configuration (e.g., `'url' => env('BUNNYCDN_CDN_URL')`). Use `Storage::disk('bunny')->url('path/to/file')` to retrieve the full CDN URL. For private files, generate signed URLs manually using BunnyCDN’s SDK or API.
- Are there alternatives to this package for BunnyCDN storage in Laravel?
- If you need a lightweight solution, you could use BunnyCDN’s PHP SDK directly with custom logic, but this lacks Flysystem’s abstraction. For Laravel-specific alternatives, consider `league/flysystem-bunnycdn` (if available) or build a custom Flysystem adapter. However, this package is the most integrated option, offering seamless Laravel filesystem compatibility and CDN support out of the box.