litlife / sitemap
此包的最新版本(0.0.1)没有可用的许可证信息。
网站地图创建模块
0.0.1
2022-02-21 12:18 UTC
Requires
- php: ^8.0
- ext-dom: *
- ext-libxml: *
- nesbot/carbon: ^2.57
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-09-21 18:12:00 UTC
README
此包用于创建网站地图
安装
使用包管理器 composer 安装。
composer require litlife/sitemap
用法
生成新的网站地图并添加新URL
use Litlife\Sitemap\Sitemap; $location = 'https://www.example.com'; $lastmod = '2005-01-01'; $changefreq = 'weekly'; $priority = 0.8; $sitemap = new Sitemap(); $sitemap->addUrl($location, $lastmod, $changefreq, $priority);
获取位置数组
$sitemap = new Sitemap(); $sitemap->getUrls();
获取XML字符串
$sitemap = new Sitemap(); $sitemap->getContent();
获取XML字节数大小
$sitemap = new Sitemap(); $sitemap->getSize();
获取当前网站地图文件中的位置数量
$sitemap = new Sitemap(); $sitemap->getUrlCount();
获取当前网站地图文件中的位置数量
$sitemap = new Sitemap(); $sitemap->getUrlCount();
打开网站地图文件
$sitemap = new Sitemap(); $sitemap->open('/path/to/file.xml');
打开网站地图索引文件
use Litlife\Sitemap\SitemapIndex; $index = new SitemapIndex(); $index->open('/path/to/sitemap_index.xml');
添加网站地图
$location = 'https://www.example.com/sitemap_index.xml'; $lastmod = '2005-01-01'; $index = new SitemapIndex(); $index->addSitemap($location, $lastmod);
获取网站地图数量
$index = new SitemapIndex(); $index->getSitemapsCount();
获取网站地图列表
$index = new SitemapIndex(); $index->getSitemaps();
获取网站地图的XML字符串
$index = new SitemapIndex(); $index->getContent();
测试
composer test