PHP code example of smknstd / fakerphp-picsum-images

1. Go to this page and download the library: Download smknstd/fakerphp-picsum-images 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/ */

    

smknstd / fakerphp-picsum-images example snippets


$faker = \Faker\Factory::create();
$faker->addProvider(new \Smknstd\FakerPicsumImages\FakerPicsumImagesProvider($faker));

// return a string that contains a url like 'https://picsum.photos/800/600/'
$faker->imageUrl(width: 800, height: 600); 

// return a string that contains a url which returns the same random image based on the provided seed
$filePath= $faker->image(width: 800, height: 800, seed: '[email protected]');

// download a properly sized image from picsum into a file with a file path like '/tmp/13b73edae8443990be1aa8f1a483bc27.jpg'
$filePath= $faker->image(dir: '/tmp', width: 640, height: 480);