clickandmortar/rekognition-php
Simple PHP library for AWS Rekognition. Detect labels (objects, scenes, concepts) and text in JPEG/PNG images. Works with image URLs, raw file bytes, or base64, returning easy-to-filter results by confidence.
aws/aws-sdk-php (≥v3.x) as a dependency. Version conflicts may arise if the project uses an older SDK (e.g., v2).composer.json or use a wrapper to abstract AWS client initialization.~/.aws/credentials. May need adjustments for dynamic credential providers (e.g., ECS task roles).AwsException). Custom error mapping may be needed for business logic (e.g., retries, dead-letter queues).guzzlehttp/guzzle)?DetectLabels, CompareFaces) in a staging environment.composer require clickandmortar/rekognition-php).class RekognitionService {
private $rekognition;
public function __construct() {
$this->rekognition = new \ClickAndMortar\Rekognition\Rekognition(
new Aws\Rekognition\RekognitionClient([
'region' => 'us-east-1',
'version' => 'latest'
])
);
}
public function detectLabels(string $imagePath): array {
return $this->rekognition->detectLabels($imagePath);
}
}
aws/aws-sdk-php to a specific version (e.g., ^3.180) to avoid breaking changes.composer why-not to check for version conflicts.aws/aws-sdk-php version. Test with the same minor version (e.g., if using SDK 3.180, avoid 3.181+).$this->app->singleton(RekognitionService::class, function ($app) {
return new RekognitionService();
});
DetectLabels, RecognizeCelebrity).Aws\Common\Exception\RetryException).'debug' => true in client config) for troubleshooting.DetectLabels supports MaxLabels).DetectLabels costs $1.00 per 1,000 images).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| AWS Rekognition API downtime | No image analysis | Implement fallback to a local model (e.g., TensorFlow) or queue for later processing. |
| Throttling (429 errors) | Slow processing | Exponential backoff + SQS DLQ for retries. |
| Credential expiration | Auth failures | Use IAM roles (ECS/Lambda) or short-lived credentials (e.g., STS). |
| Package deprecation | Broken functionality | Fork/maintain internally or migrate to AWS SDK directly |
How can I help you explore Laravel packages today?