定制 middlewares/robots 二次开发

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

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

middlewares/robots

最新稳定版本:v2.1.0

Composer 安装命令:

composer require middlewares/robots

包简介

Middleware to enable/disable the robots of the search engines

README 文档

README

Latest Version on Packagist Software License Testing Total Downloads

Middleware to enable/disable the robots of the search engines for non-production environment. Adds automatically the header X-Robots-Tag in all responses and returns a default body for /robots.txt request.

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/robots.

composer require middlewares/robots

Example

$dispatcher = new Dispatcher([
    new Middlewares\Robots(false)
]);

$response = $dispatcher->dispatch(new ServerRequest());

echo $response->getHeaderLine('X-Robots-Tag'); //noindex, nofollow, noarchive

Usage

The constructor's first argument configure whether block or not search engines.

//Disallow search engine robots
$robots = new Middlewares\Robots(false);

//Allow search engine robots
$robots = new Middlewares\Robots(true);

Optionally, you can provide a Psr\Http\Message\ResponseFactoryInterface as the second argument to create the response of the requests to /robots.txt. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.

$responseFactory = new MyOwnResponseFactory();

$robots = new Middlewares\Robots(false, $responseFactory);

sitemap

If your site has a sitemap, use this option to add the url to robots.txt responses.

$robots = (new Middlewares\Robots(true))->sitemap('/sitemap.xml');

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-05