1. Go to this page and download the library: Download chuoke/unify-gallery 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/ */
chuoke / unify-gallery example snippets
use Chuoke\MediaBridge\MediaManager;
$manager = new MediaManager([
'default' => 'unsplash',
'drivers' => [
'unsplash' => ['api_key' => 'your-unsplash-key'],
'pexels' => ['api_key' => 'your-pexels-key'],
'pixabay' => ['api_key' => 'your-pixabay-key'],
],
]);
// Search photos
$result = $manager->driver('pexels')->search('mountain', page: 1, perPage: 20);
// Browse without query (Bing, Wikimedia; NASA falls back to a generic feed)
$result = $manager->driver('bing')->search();
// Use default driver
$result = $manager->search('ocean');
foreach ($result->items as $item) {
echo $item->source; // 'pexels'
echo $item->url; // full image URL
echo $item->thumb_url; // thumbnail URL
print_r($item->variants); // available size / asset variants
echo $item->author_name; // photographer name
echo $item->license; // 'pexels', 'cc0', etc.
}