PHP code example of joukhar / laravel-pixabay

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

    

joukhar / laravel-pixabay example snippets


return [
    'key' => env('PIXABAY_API_KEY'),
];

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getImages();

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getImages(id:"< IMAGE ID HERE >");

use Joukhar\LaravelPixabay\Enums\PixabayImageType;

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getImages(type: PixabayImageType::ILLUSTRATION );

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getVideos();

use Joukhar\LaravelPixabay\Enums\PixabayVideoType;

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getVideos(type: PixabayVideoType::ANIMATION);

$laravelPixabay = new Joukhar\LaravelPixabay();
$laravelPixabay->getVideos(id:"< VIDEO ID HERE >");

$pixabay->setCurrentPage(2);

$pixabay->setMaxResults(50);

$pixabay->setSafeSearch(true);

$pixabay->setOnlyEditorChoice(true);

use Joukhar\LaravelPixabay\Enums\PixabayCategory;

$pixabay->setCategory(PixabayCategory::NATURE);

$pixabay->setOrder('latest');

$pixabay->setDimentions(800, 600);

use Joukhar\LaravelPixabay\LaravelPixabay;
use Joukhar\LaravelPixabay\Enums\PixabayCategory;
use Joukhar\LaravelPixabay\Enums\PixabayImageType;

$pixabay = new LaravelPixabay();
$photos = $pixabay
    ->setCategory(PixabayCategory::NATURE)
    ->setMaxResults(10)
    ->setSafeSearch(true)
    ->getImages(null, PixabayImageType::PHOTO);

try {
    $images = $pixabay->getImages();
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

bash
php artisan vendor:publish --tag="laravel-pixabay-config"