PHP code example of justraviga / laravel-pexels

1. Go to this page and download the library: Download justraviga/laravel-pexels 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/ */

    

justraviga / laravel-pexels example snippets


use JustRaviga\Pexels\Clients\PhotoApiClient;
use JustRaviga\Pexels\Facades\Pexels;

$client = new PhotoApiClient(); // Good for controller method/artisan command handle()/job handle() dependency injection
// OR
$client = Pexels::photos();

$response = $client->search('cats');

foreach ($response->photos as $photo){
    $photo->width;
    $photo->height;
    $photo->url;
    $photo->src->medium;
}