PHP Classes


Recommend this page to a friend!
  Classes of Emil Kilhage   PHP Pexels API   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Pexels API
Search for photos in the Pexels site using its API
Author: By
Last change: Update
Date: 4 years ago
Size: 2,752 bytes


Class file image Download

Pexels API Client

Scrutinizer Code Quality Build Status Latest Stable Version Total Downloads License


Install the Pexels API Client with Composer.

"require": {
    "glooby/pexels": "~0.1"


Create an instance of the Pexels API Client by passing in your API token as parameter.

$pexels = new \Glooby\Pexels\Client("xxxxx");

Perform a search, the response gets returned as an array

$response = $pexels->search('london');

Loop trough photos and display them

$photos = json_decode($pexels->search('london')->getBody())->photos;
foreach ($photos as $photo) {
 echo "<img src='{$photo->src->small}' width='{$photo->width}' heigth='{$photo->height}'>"

Example response