PHP code example of larareko / aws-rekognition

1. Go to this page and download the library: Download larareko/aws-rekognition library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

larareko / aws-rekognition example snippets



// config/app.php

return [

    // ...

    'providers' => [

        // ...

        /*
         * Package Service Providers...
         */
        Larareko\Rekognition\RekognitionServiceProvider::class, // [a]

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

    ],

    // ...

    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,

        // ...

        'Rekognition' => 'Larareko\Rekognition\RekognitionFacade', // [b]
        'Hash' => Illuminate\Support\Facades\Hash::class,

        // ...
    ],

];




class LabelDetectionImage extends Model
{
    /**
     * Upload image to S3
     *
     * @param Illuminate\Http\UploadedFile  $file
     *
     * @return string
     */
    public function upload(UploadedFile $file) : string
    {
        $name = time() . $file->getClientOriginalName();
        
        \Rekognition::uploadImageToS3(file_get_contents($file), null, self::BUCKET, $name);
        
        return $name;
    }
}