ptrufanov1/sitemap-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ptrufanov1/sitemap-generator

最新稳定版本:v1.0.7

Composer 安装命令:

composer require ptrufanov1/sitemap-generator

包简介

Generate sitemap file. File format supports: xml, JSON, csv

README 文档

README

Generate sitemap file from php. Available formats: xml, json, csv.

Installation

Installation via Composer

composer require ptrufanov1/sitemap-generator

That, make sure your application autoload Composer classes by including vendor/autoload.php.

require "vendor/autoload.php";

Requirements

The minimum requirement by this project template that your Web server supports PHP 8.0.

How to use it

require_once "vendor/autoload.php";

use Ptrufanov1\SitemapGenerator\Sitemap;

$pages = [
	[
		'loc' => 'https://site.ru/',
		'lastmod' => '2022-10-14',
		'priority' => 1,
		'changefreq' => 'hourly',

	],
	[
		'loc' => 'https://site.ru/news',
		'lastmod' => '2022-10-10',
		'priority' => 0.5,
		'changefreq' => 'daily',

	],
	[
		'loc' => 'https://site.ru/about',
		'lastmod' => '2022-10-07',
		'priority' => 0.1,
		'changefreq' => 'weekly',

	],
	[
		'loc' => 'https://site.ru/products',
		'lastmod' => '2022-10-12',
		'priority' => 0.5,
		'changefreq' => 'daily',

	],
	[
		'loc' => 'https://site.ru/products/ps5',
		'lastmod' => '2022-10-11',
		'priority' => 0.1,
		'changefreq' => 'weekly',

	],
	[
		'loc' => 'https://site.ru/products/xbox',
		'lastmod' => '2022-10-12',
		'priority' => 0.1,
		'changefreq' => 'weekly',

	],
	[
		'changefreq' => 'weekly',
		'priority' => 0.3,
		'lastmod' => '2022-10-15',
		'loc' => 'https://site.ru/products/wii',

	]
];

/* Path to save sitemap file */
$path = $_SERVER['DOCUMENT_ROOT']."/sitemap/";

try {
	if (Sitemap::load($pages)->saveXml($path)) {
        echo "Sitemap save successful!";
    }
} catch (Exception $e) {
	echo "Error sitemap generate: ".$e->getMessage();
}

Use cases

Generate xml sitemap file

Sitemap::load($pages)->saveXml($path)

Generate csv sitemap file

Sitemap::load($pages)->saveCsv($path)

Generate JSON sitemap file

Sitemap::load($pages)->saveJson($path)

Return true if file successful generate. Or throw an exception on error.

MIT License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固