-
Couldn't load subscription status.
- Fork 3
Learn the API
I'd like to show you how to use the API for each class: UrlSet, Url, SitemapIndex and Sitemap.
This is the class that you would want to use if you were creating a sitemap.
use Laravelista\Bard\UrlSet;
use Sabre\Xml\Writer;
$sitemap = new UrlSet(new Writer)This method adds a Url to the sitemap (UrlSet).
-
$locationis required and it must be a valid URL.
$sitemap->addUrl('http://acme.me');This method also return the instance of class Url. If you want to know what you can do with that instance see Url.
You will probably not use this method, but if you insist you will get the sitemap XML output in string type.
return $sitemap->generate();Now this is a method that you will want to use. It returns output from generate() method as XML response.
return $sitemap->render();This class is only used from UrlSet class as a returned object from addUrl method. See addUrl.
This will validate given URL and set it as Url location.
You will probably never use this because the location is set when calling the
addUrlmethod.
-
$urlmust be a valid URL.
$sitemap->addUrl('http://acme.me')
->setLocation('http://acme.me/different-path');This method sets the last modification date on Url.
-
$lastModificationmust beDateTime. You can use Carbon to set the date.
$sitemap->addUrl('http://acme.me')
->setLastModification(\Carbon\Carbon::now());This adds a translation.
-
localecan be any string. -
$urlmust be a valid URL.
$sitemap->addUrl('http://acme.me')
->addTranslation('hr', 'http://acme.me/hr');This sets priority for Url.
-
$prioritymust be a number between>=0.0 && <= 1.0
$sitemap->addUrl('http://acme.me')
->setPriority(0.8)This sets the change frequency for Url.
-
$changeFrequencycan be:"always", "hourly", "daily", "weekly", "monthly", "yearly", "never".
$sitemap->addUrl('http://acme.me')
->setChangeFrequency('hourly');This is the class that you would want to use if you were creating a sitemap index.
use Laravelista\Bard\SitemapIndex;
use Sabre\Xml\Writer;
$sitemapIndex = new SitemapIndex(new Writer);This will add a sitemap to sitemap index.
-
$locationis required and it must be a valid URL.
$sitemapIndex->addSitemap('http://acme.me/sitemap-tags.xml');This method also return the instance of class Sitemap. If you want to know what you can do with that instance see Sitemap.
You will probably not use this method, but if you insist you will get the sitemap index XML output in string type.
return $sitemapIndex->generate();Now this is a method that you will want to use. It returns output from generate() method as XML response.
return $sitemapIndex->render();This class is only used from SitemapIndex class as a returned object from addSitemap method. See addSitemap.
This will validate given URL and set it as sitemap location.
You will probably never use this because the location is set when calling the
addSitemapmethod.
-
$locationmust be a valid URL.
$sitemapIndex->addSitemap('http://acme.me/sitemap-tags.xml')
->setLocation('http://acme.me/sitemap-tags-index.xml');This method sets the last modification date on sitemap.
-
$lastModificationmust beDateTime. You can use Carbon to set the date.
$sitemapIndex->addSitemap('http://acme.me/sitemap-tags.xml')
->setLastModification(\Carbon\Carbon::now());- The cool image with Bard flying and Bard logo are from Bard, the Wandering Caretaker revealed website.