joaquinpereira/laravel-pexels

library to consume the pexels api (https://www.pexels.com/)

dev-master 2023-07-17 20:48 UTC

This package is auto-updated.

Last update: 2024-04-17 22:20:23 UTC


README

This is a package made for laravel, that connects to the pexels api and gets images or videos.

Requirements

Installation

composer require joaquinpereira/laravel-pexels

Configuration

You must publish the config/pexel.php configuration file with the following command:

php artisan vendor:publish --provider="joaquinpereira\Pexels\Providers\PexelsServiceProvider" --tag="config"

In the .env file of the project you must add the following key PEXELS_API_KEY and place the value of your key provided by the pexels site

PEXELS_API_KEY="YOUR_PEXELS_API_KEY"

Examples of use:

use joaquinpereira\Pexels\Facades\Pexels;

Route::get('/pexels', function () {
	
	//Images
    dump(Pexels::image_search('modern apartment'));
    dump(Pexels::image_search('modern apartment',20, 25));
    dump(Pexels::image_curated());
    dump(Pexels::image_curated(3,15));
    dump(Pexels::image_detail(17579690));
    dump(Pexels::getRandomImage('beach','landscape'));

	//videos
    dump(Pexels::video_search('android robot'));
    dump(Pexels::video_search('android robot', 3, 15));
    dump(Pexels::popular_videos());
    dump(Pexels::popular_videos(5,20));    
    dump(Pexels::getRandomVideo('dogs'));
    dump(Pexels::video_detail(15570408));
});