- How do I install this package in a Laravel project?
- Run `composer require clickandmortar/rekognition-php` in your project root. Ensure your Laravel app meets the PHP 7.2+ requirement and has the AWS SDK v3 installed as a dependency. The package will integrate seamlessly with Laravel’s service container for dependency injection.
- Does this package support AWS Rekognition v2 features like DetectModerationLabels?
- No, this package was last updated in 2019 and primarily supports Rekognition v1 APIs like DetectLabels and DetectText. For v2 features, you’ll need to use the official AWS SDK directly or consider a more actively maintained wrapper.
- Can I use this package with Laravel’s queue system for async image processing?
- The package itself doesn’t support async operations or event-driven workflows like SQS/SNS integration. You’ll need to manually dispatch jobs to Laravel queues and handle Rekognition responses in the job’s handle method, then process results asynchronously.
- What Laravel versions does this package officially support?
- The package targets PHP 7.2+, which aligns with Laravel 5.8+ and later. However, since it’s a thin wrapper around the AWS SDK, it should work with any Laravel version that supports PHP 7.2+. Test thoroughly in your environment.
- How do I handle AWS credentials in a Laravel deployment (e.g., Lambda, ECS, or EC2)?
- For serverless (Lambda/ECS), use IAM roles for automatic credential provisioning. For EC2 or local development, configure credentials via ~/.aws/credentials or environment variables. Laravel’s `aws/aws-sdk-php` dependency will automatically resolve credentials from these sources.
- Is there a way to filter results by confidence level in the response?
- Yes, the package provides methods like `getLabels($minimumConfidence)` and `getTexts($minimumConfidence)` to filter results by confidence percentage. For example, `$rekognitionImage->getLabels(80)` will return only labels with 80%+ confidence.
- What are the alternatives if this package isn’t actively maintained?
- Consider the official AWS SDK (`aws/aws-sdk-php`) for full feature support, or a more modern wrapper like `spatie/laravel-aws` for Laravel-specific integrations. For async workflows, explore event-driven architectures with SQS/SNS and the AWS SDK directly.
- How do I handle errors or throttling from AWS Rekognition?
- The package throws `AwsException` for AWS errors. Implement custom error handling in your Laravel app, such as retry logic with exponential backoff or dead-letter queues for failed jobs. Monitor throttling via AWS CloudWatch metrics.
- Can I use this package with Laravel’s filesystem to process uploaded images?
- Yes, you can use Laravel’s `Storage` facade to read uploaded files (e.g., from `request()->file('image')`) and pass the raw bytes to the package’s `detect()` method. Example: `$imageBytes = file_get_contents(storage_path('app/' . $file->hashName()));`
- What’s the best way to test this package in a Laravel application?
- Mock the AWS Rekognition client using Laravel’s `Mockery` or `PHPUnit` to avoid real API calls. Test edge cases like malformed images, low-confidence results, and error responses. Use Laravel’s `HttpTests` trait for integration testing with real AWS credentials in a staging environment.