承接 artemperepechai/sitemap 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

artemperepechai/sitemap

Composer 安装命令:

composer require artemperepechai/sitemap

包简介

Sitemap and sitemap index builder

关键字:

README 文档

README

Sitemap and sitemap index builder.

Features

  • Create sitemap files.
  • Create sitemap index files.
  • Automatically creates new file if 50000 URLs limit is reached.
  • Memory efficient buffer of configurable size.

Installation

in composer.json

"require": { "artemPerepechai/sitemap" : "dev-master" }, "repositories": [ { "url": "https://github.com/artemPerepechai/sitemap", "type": "vcs" } ],

After that, make sure your application autoloads Composer classes by including vendor/autoload.php.

How to use it

use samdark\sitemap\Sitemap;
use samdark\sitemap\Index;

// create sitemap
$sitemap = new Sitemap(__DIR__ . '/sitemap.xml');

// add some URLs
$sitemap->setLocation('http://example.com/mylink4')
        ->setLastModified(time())
        ->setFrequency(Sitemap::DAILY)
        ->setAlternateLanguage('en', 'http://example.com/en')
        ->setAlternateLanguage('de', 'http://example.com/de')
        ->setAlternateLanguage('fr', 'http://example.com/fr')
        ->setPriority(0.1)
        ->addItem();

// write it
$sitemap->write();

// get URLs of sitemaps written
$sitemapFileUrls = $sitemap->getSitemapUrls('http://example.com/');

// create sitemap for static files
$staticSitemap = new Sitemap(__DIR__ . '/sitemap_static.xml');

// add some URLs
$staticSitemap->setLocation('http://example.com/about')
              ->setLastModified(time())
              ->addItem();
              
$staticSitemap->setLocation('http://example.com/tos')
              ->setLastModified(time())
              ->addItem();
              
$staticSitemap->setLocation('http://example.com/jobs')
              ->setLastModified(time())
              ->addItem();

// write it
$staticSitemap->write();

// get URLs of sitemaps written
$staticSitemapUrls = $staticSitemap->getSitemapUrls('http://example.com/');

// create sitemap index file
$index = new Index(__DIR__ . '/sitemap_index.xml');

// add URLs
foreach ($sitemapFileUrls as $sitemapUrl) {
    $index->addSitemap($sitemapUrl);
}

// add more URLs
foreach ($staticSitemapUrls as $sitemapUrl) {
    $index->addSitemap($sitemapUrl);
}

// write it
$index->write();

Options

There are two methods to configre Sitemap instance:

  • setMaxUrls($number). Sets maximum number of URLs to write in a single file. Default is 50000 which is the limit according to specification and most of existing implementations.
  • setBufferSize($number). Sets number of URLs to be kept in memory before writing it to file. Default is 1000. If you have more memory consider increasing it. If 1000 URLs doesn't fit, decrease it.
  • setUseIndent($bool). Sets if XML should be indented. Default is true.

Running tests

In order to run tests perform the following commands:

composer install
phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-10-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固