PHP code example of emanueleminotto / faker-placehold-it-provider

1. Go to this page and download the library: Download emanueleminotto/faker-placehold-it-provider 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/ */

    

emanueleminotto / faker-placehold-it-provider example snippets


$faker = Faker\Factory::create();
$faker->addProvider(new EmanueleMinotto\Faker\PlaceholdItProvider($faker));

// size
$url = $faker->imageUrl(50); // http://placehold.it/50.gif
$url = $faker->imageUrl('50x100'); // http://placehold.it/50x100.gif
$url = $faker->imageUrl(array(50, 100)); // http://placehold.it/50x100.gif
$url = $faker->imageUrl(array('w' => 100, 'h' => 50)); // http://placehold.it/50x100.gif

// format
// can be gif, jpeg, jpg or png
$url = $faker->imageUrl(50); // http://placehold.it/50.gif
$url = $faker->imageUrl(50, 'jpeg'); // http://placehold.it/50.jpeg
$url = $faker->imageUrl(50, 'jpg'); // http://placehold.it/50.jpg
$url = $faker->imageUrl(50, 'png'); // http://placehold.it/50.png

// colors
$url = $faker->imageUrl(50, null, array('000', 'fff')); // http://placehold.it/50.gif/000/fff
$url = $faker->imageUrl(50, null, array('w' => 100, 'h' => 100)); // http://placehold.it/50.gif/000/fff

// text
$url = $faker->imageUrl(50, null, array(), 'lorem ipsum'); // http://placehold.it/50.gif?text=lorem+ipsum