Exemplo n.º 1
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use Sitemapper\Generator;
use Sitemapper\Url;
use Sitemapper\Image;
use Faker\Factory;
$faker = Factory::create();
$host = rtrim($faker->url, '/');
$generator = new \Sitemapper\Generator();
$generator->setOutputDir(sys_get_temp_dir());
$generator->setHostname($host);
$generator->setOverwrite(true);
$generator->setAutoSave(true);
$generator->setMaxAllowedUrls(10000);
$generator->setCompress(true);
for ($i = 0; $i < 100000; $i++) {
    $url = $host . '/' . $faker->uuid;
    echo $i . '=> ' . $url . PHP_EOL;
    $generator->addUrl(new Url($url));
}
$generator->generate();
Exemplo n.º 2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
date_default_timezone_set('America/Sao_Paulo');
use Sitemapper\Generator;
use Sitemapper\Url;
use Sitemapper\Image;
use Faker\Factory;
$faker = Factory::create();
$host = rtrim($faker->url, '/');
$generator = new \Sitemapper\Generator();
$generator->setOutputDir(sys_get_temp_dir());
$generator->setHostname($host);
$generator->setOverwrite(true);
$generator->setAutoSave(true);
$generator->setMaxAllowedUrls(10000);
$generator->setCompress(true);
for ($i = 0; $i < 100000; $i++) {
    $loc = $host . '/' . $faker->uuid;
    echo $i . '=> ' . $loc . PHP_EOL;
    $randPriority = rand(Url::PRIORITY_LOW, Url::PRIORITY_HIGH);
    $url = new Url($loc, $faker->iso8601, Url::CHANGE_FREQUENCY_DAILY, $randPriority);
    // Adding images
    for ($j = 1; $j < $faker->randomDigit; $j++) {
        $url->addImage(new Image($loc, $faker->catchPhrase));
    }
    $generator->addUrl($url);
}
$generator->generate();
Exemplo n.º 3
0
 public function testShouldNotify()
 {
     $generator = new Generator();
     $generator->setOutputDir($this->outputDir);
     $generator->setHostname('http://www.example.com');
     $generator->setCompress(true);
     $generator->addUrl(new Url('/'));
     $generator->addUrl(new Url('/path1'));
     $generator->addUrl(new Url('/path2', '2014-01-01'));
     $notifier = $this->getMock('\\Sitemapper\\EngineNotifier', array('notify'));
     $notifier->expects($this->once())->method('notify')->with($generator->getLocation());
     $generator->addNotifier($notifier);
     $generator->generate();
 }