PHP code example of teariot / faker-fillthis

1. Go to this page and download the library: Download teariot/faker-fillthis 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/ */

    

teariot / faker-fillthis example snippets


use Faker\Factory;
use TeaRiot\FakerFillThis\Faker\Provider\FillThisImage;

$faker = Factory::create();
$faker->addProvider(new FillThisImage($faker));

  echo $faker->imageUrl(0, 0);
  

  echo $faker->imageUrl(500, 500, null, false, null, false, "png");
  

  echo $faker->imageUrl(800, 600, null, true, null, false, "png");
  

  echo $faker->imageUrl(0, 0, "fashion", false, null, false, "png");
  

echo $faker->url('video');

$imagePath = $faker->image(__DIR__, 800, 600, null, true, true, "TestImage", false, "png");
if ($imagePath !== false) {
    echo "Image downloaded at: " . $imagePath;
} else {
    echo "Error downloading image.";
}

  imageUrl(
      int $width = 640,
      int $height = 480,
      ?string $category = null,
      bool $randomize = true,
      ?string $word = null,
      bool $gray = false,
      string $format = 'png'
  ): string
  

  url(?string $type = null): string
  

  image(
      ?string $dir = null,
      int $width = 640,
      int $height = 480,
      ?string $category = null,
      bool $fullPath = true,
      bool $randomize = true,
      ?string $word = null,
      bool $gray = false,
      string $format = 'png'
  ): string|false