PHP code example of sparkapi / feed-faker

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

    

sparkapi / feed-faker example snippets


$settings = [
    // ' => 'your_unsplash_app_id', // unsplash specific
    'interior_collection' => collection_id, // unsplash collection or filesystem path if using local photo provider
    'exterior_collection' => collection_id, // unsplash collection or filesystem path if using local photo provider
    'portrait_collection' => collection_id, // unsplash collection or filesystem path if using local photo provider
        
    // Optional photo provider, if not using unsplash (you can ignore the above, too).
    'photo_provider' => \FeedFaker\Helper\UnsplashPhotoProvider::class,

    // Basic settings, all with defaults.
    'mls_id' => 'my-awesome-mls',
    
    // the number of objects you want to create for each resource type.
    'office_count' => 50,
    'member_count' => 150,
    'property_count' => 500,
    'openhouse_count' => 1000,
    'history_count' => 1000,
    'media_count' => 5000,
];

$settings = [
    'unsplash_app_id' => 'my-app-id-from-unsplash'
    'interior_collection' => 10
    'exterior_collection' => 1010
    'portrait_collection' => 101010
    
    // optional
    'mls_id' => 'best-mls-in-the-universe',
    'history_count' => 500
];

$feedfake = new FeedFaker\FakeFeed();
$data = $feedfake->go($settings);

$properties = $data['property'];
$offices = $data['office'];
$members = $data['member'];
$media = $data['media'];
$history = $data['history'];
$openhouses = $data['openhouse'];

foreach ($properties as $property) {
    echo $property->getListingKey() . PHP_EOL;

    var_dump($property->toArray());
}

$logger_setup = function($monolog) {
    // Save all debug and above messages to a file
    $monolog->pushHandler(new StreamHandler('/path/to/logs.log', \Monolog\Logger::DEBUG));
    
    // Save more important messages to some other place
    $monolog->pushHandler(new SomeOtherHandler(\Monolog\Logger::WARNING));
};

$feedfake = new FeedFaker\FakeFeed([], $logger_setup);
$data = $feedfake->go()

$feedfake = new FeedFaker\FakeFeed([], $my_psr_3_logger);
$data = $feedfake->go()