定制 arcanedev/robots 二次开发

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

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

arcanedev/robots

最新稳定版本:2.0.0

Composer 安装命令:

composer require arcanedev/robots

包简介

Robots.txt generator

README 文档

README

Travis Status HHVM Status Coverage Status Scrutinizer Code Quality SensioLabs Insight Github Issues

Packagist Packagist Release Packagist Downloads

By ARCANEDEV©

Features

  • Framework agnostic package.
  • Well documented & IDE Friendly.
  • Well tested with maximum code quality.
  • Laravel 4.2 supported.
  • Laravel 5 supported.
  • Made with ❤️ & ☕.

Requirements

- PHP >= 5.5.9

INSTALLATION

Composer

You can install this package via Composer. Add this to your composer.json :

{
    "require": {
        "arcanedev/robots": "~2.0"
    }
}

Then install it via composer install or composer update.

Laravel

Setup

Once the package is installed, you can register the service provider in config/app.php in the providers array:

'providers' => [
    ...
    Arcanedev\Robots\RobotsServiceProvider::class,
],

And the facade in the aliases array:

'aliases' => [
    ...
    'Robots' => Arcanedev\Robots\Facades\Robots::class,
],

USAGE

Laravel

The quickest way to use Robots is to just setup a callback-style route for robots.txt in your app/routes.php file.

Route::get('robots.txt', function() {

    // If on the live server, serve a nice, welcoming robots.txt.
    if (App::environment() == 'production') {
        Robots::addUserAgent('*');
        Robots::addSitemap('sitemap.xml');
    }
    else {
        // If you're on any other server, tell everyone to go away.
        Robots::addDisallow('*');
    }

    return Response::make(Robots::generate(), 200, ['Content-Type' => 'text/plain']);
});

Hard Coded

Add a rule in your .htaccess for robots.txt that points to a new script (or something else) that generate the robots file.

The code would look something like:

require_once __DIR__ . '/../vendor/autoload.php';

use Arcanedev\Robots\Robots;

$robots = new Robots;

$robots->addUserAgent('Google');
$robots->addDisallow(['/admin/', '/login/', '/secret/']);
$robots->addSpacer();
$robots->addSitemap('sitemap.xml');

header('HTTP/1.1 200 OK');
echo $robots->generate();

TODOS

  • Documentation

DONE

  • Framework agnostic package.
  • Examples
  • Laravel v4.2 Support.
  • Laravel v5.0 Support.
  • Laravel v5.1 Support.

Contribution

Any ideas are welcome. Feel free to submit any issues or pull requests, please check the contribution guidelines.

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-14