定制 vinex56/sitemap-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vinex56/sitemap-generator

Composer 安装命令:

composer require vinex56/sitemap-generator

包简介

Library for generating website sitemaps in XML, CSV, and JSON formats.

README 文档

README

Sitemap Generator is a PHP library for generating sitemaps in XML, CSV, and JSON formats. This library allows you to easily create sitemaps for your website and save them in the desired format.

Installation

You can install the library via Composer. Run the following command in your project directory:

composer require vinex56/sitemap-generator:dev-master

Usage

Here is an example of how to use the Sitemap Generator:

require 'vendor/autoload.php';
use Vinex56\SitemapGenerator\SitemapGenerator;
$pages = [
    [
        'loc' => 'https://site.ru/',
        'lastmod' => '2020-12-14',
        'priority' => '1',
        'changefreq' => 'hourly'
    ],
    [
        'loc' => 'https://site.ru/news',
        'lastmod' => '2020-12-10',
        'priority' => '0.5',
        'changefreq' => 'daily'
    ],
    [
        'loc' => 'https://site.ru/about',
        'lastmod' => '2020-12-07',
        'priority' => '0.1',
        'changefreq' => 'weekly'
    ]
];
try {
    $sitemap = new SitemapGenerator($pages, 'json', __DIR__ . '/upload/sitemap.json');
    $sitemap->generate();
    echo "Sitemap generated successfully.\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Features

Supports generating sitemaps in XML, CSV, and JSON formats. Automatically creates the directory for the sitemap file if it doesn't exist. Validates input data to ensure proper sitemap generation. Throws custom exceptions for various errors (e.g., invalid data, file write errors).

Requirements

  • PHP 7.4 or higher
  • Composer

License

This library is licensed under the MIT License. See the LICENSE file for more details.

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-15