venkatesh-kcet / sitemap
网站地图生成器
v1.0.0
2023-06-17 04:18 UTC
This package is not auto-updated.
Last update: 2024-09-22 08:58:08 UTC
README
描述
网站地图生成器库是一个作为PHP Composer包实现的学生项目。它提供了一个简单高效的方式来生成网站的网站地图。这个库允许您创建搜索引擎可以使用的XML网站地图,以发现和索引您网站上的页面。
特性
- 易于使用的API用于生成网站地图
- 支持不同类型的URL(例如,网页、图片、视频、新闻)
- 自动处理网站地图限制(例如,每个网站地图的最大URL数量,网站地图索引创建)
- 可自定义的选项来配置网站地图生成过程
- 高效且可扩展,适用于大型网站
- 与流行的PHP框架和内容管理系统兼容
安装
您可以使用Composer安装网站地图生成器库
composer require venkatesh-kcet/sitemap
用法
以下是如何使用网站地图生成器库的简单示例
URL网站地图
<?php include "vendor/autoload.php"; use VenkateshKcet\Sitemap\Sitemap; $sitemap = new Sitemap(); $array = [ 'loc' => "https://pypi.ac.cn/search/?q=sitemap", ]; $sitemap->add_url($array); $sitemap->write_sitemap(__DIR__, 1000); $sitemap->write_sitemapIndex($folderPath = __DIR__, $path = "https:///sitemap/");
图片网站地图
<?php include "vendor/autoload.php"; use VenkateshKcet\Sitemap\Sitemap; $sitemap = new Sitemap(); $array = [ 'loc' => "https://pypi.ac.cn/search/?q=sitemap", 'images' => ["https://pypi.ac.cn/search/1.png", "https://pypi.ac.cn/search/2.png"] ]; $sitemap->add_url($array); $sitemap->write_sitemap(__DIR__, 1000); $sitemap->write_sitemapIndex($folderPath = __DIR__, $path = "https:///sitemap/");
视频网站地图
<?php include "vendor/autoload.php"; use VenkateshKcet\Sitemap\Sitemap; $sitemap = new Sitemap(); $array = [ 'loc' => "https://pypi.ac.cn/search/?q=sitemap", 'videos' => [ 0 => [ "thumbnail_loc" => "https://www.example.com/thumbs/123.jpg", "title" => "Grilling steaks for summer", "description" => "Alkis shows you how to get perfectly done steaks every time", "content_loc" => "http://streamserver.example.com/video123.mp4", "player_loc" => "https://www.example.com/videoplayer.php?video=123", "duration" => 600, "expiration_date" => "2021-11-05T19:20:30+08:00", "rating" => 4.2, "view_count" => 12345, "publication_date" => "2007-11-05T19:20:30+08:00", "family_friendly" => "yes", "restriction" => [ "relationship" => "allow", "value" => ["IE", "GB", "US", "CA"] ], "platform" => [ "relationship" => "allow", "value" => ["web", "tv"] ], "price" => [ "currency" => "EUR", "value" => 1.99 ], "requires_subscription" => "yes", "uploader" => [ "info" => "https://www.example.com/users/grillymcgrillerson", "value" => "GrillyMcGrillerson" ], "live" => "no", "tag" => ["steak", "meat", "summer", "outdoor"] ], 1 => [ "thumbnail_loc" => "https://www.example.com/thumbs/123.jpg", "title" => "Grilling steaks for summer", "description" => "Alkis shows you how to get perfectly done steaks every time", "content_loc" => "http://streamserver.example.com/video123.mp4", "player_loc" => "https://www.example.com/videoplayer.php?video=123" ] ] ]; $sitemap->add_url($array); $sitemap->write_sitemap(__DIR__, 1000); $sitemap->write_sitemapIndex($folderPath = __DIR__, $path = "https:///sitemap/");
新闻网站地图
<?php include "vendor/autoload.php"; use VenkateshKcet\Sitemap\Sitemap; $sitemap = new Sitemap(); $array = [ 'loc' => "https://pypi.ac.cn/search/?q=sitemap", 'news' => [ 'publication' => [ 'name' => 'The Example Times', 'language' => 'en' ], 'publication_date' => '2008-12-23', 'title' => 'Companies A, B in Merger Talks' ] ]; $sitemap->add_url($array); $sitemap->write_sitemap(__DIR__, 1000); $sitemap->write_sitemapIndex($folderPath = __DIR__, $path = "https:///sitemap/");
组合网站地图
<?php include "vendor/autoload.php"; use VenkateshKcet\Sitemap\Sitemap; $sitemap = new Sitemap(); $array = [ 'loc' => "https://pypi.ac.cn/search/?q=sitemap", 'images' => ["https://pypi.ac.cn/search/1.png", "https://pypi.ac.cn/search/2.png"], 'videos' => [ 0 => [ "thumbnail_loc" => "https://www.example.com/thumbs/123.jpg", "title" => "Grilling steaks for summer", "description" => "Alkis shows you how to get perfectly done steaks every time", "content_loc" => "http://streamserver.example.com/video123.mp4", "player_loc" => "https://www.example.com/videoplayer.php?video=123", "duration" => 600, "expiration_date" => "2021-11-05T19:20:30+08:00", "rating" => 4.2, "view_count" => 12345, "publication_date" => "2007-11-05T19:20:30+08:00", "family_friendly" => "yes", "restriction" => [ "relationship" => "allow", "value" => ["IE", "GB", "US", "CA"] ], "platform" => [ "relationship" => "allow", "value" => ["web", "tv"] ], "price" => [ "currency" => "EUR", "value" => 1.99 ], "requires_subscription" => "yes", "uploader" => [ "info" => "https://www.example.com/users/grillymcgrillerson", "value" => "GrillyMcGrillerson" ], "live" => "no", "tag" => ["steak", "meat", "summer", "outdoor"] ], 1 => [ "thumbnail_loc" => "https://www.example.com/thumbs/123.jpg", "title" => "Grilling steaks for summer", "description" => "Alkis shows you how to get perfectly done steaks every time", "content_loc" => "http://streamserver.example.com/video123.mp4", "player_loc" => "https://www.example.com/videoplayer.php?video=123" ] ], 'news' => [ 'publication' => [ 'name' => 'The Example Times', 'language' => 'en' ], 'publication_date' => '2008-12-23', 'title' => 'Companies A, B in Merger Talks' ] ]; $sitemap->add_url($array); $sitemap->write_sitemap(__DIR__, 1000); $sitemap->write_sitemapIndex($folderPath = __DIR__, $path = "https:///sitemap/");
有关更详细的用法说明和配置选项,请参阅文档。
许可证
本项目采用MIT许可证。有关更多信息,请参阅LICENSE文件。
贡献
欢迎贡献!如果您遇到任何问题或有改进建议,请随时提交问题或提交拉取请求。
示例
以下是一些如何使用网站地图生成器库的示例
- 为简单的静态网站生成网站地图
- 将网站地图生成集成到Web应用程序中
支持
如果您需要任何帮助或有任何问题,请在GitHub上提交问题。
请随意自定义文档的内容和结构,以最好地适应您的库及其功能。