olegtatarenko / sitemap

生成网站地图的库

v1.4 2024-09-04 09:31 UTC

This package is auto-updated.

Last update: 2024-09-04 09:38:37 UTC


README

网站地图生成库

该库允许在多种文件格式中生成网站地图:xml, csv, json

安装

composer require olegtatarenko/sitemap

使用示例

<?php

require 'vendor/autoload.php';

use OlegTatarenko\Sitemap\FileCreater;

$pages = [
    [
        'loc' => 'https://site.ru/',
        'lastmod' => '2024-08-17',
        'priority' => 1,
        'changefreq' => 'hourly'
    ],
    [
        'loc' => 'https://site.ru/news',
        'lastmod' => '2024-08-17',
        'priority' => 0.5,
        'changefreq' => 'weekly'
    ]
];

$file = new FileCreater($pages, 'xml', './upload/sitemap.xml');

try {
    $file->createFileWithSiteMap();
} catch (Exception $e){
    echo $e->getMessage();
}