djstarcom/laravel-robots-manager

Laravel robots.txt manager

v2.0.1 2021-06-15 07:05 UTC

This package is auto-updated.

Last update: 2024-04-16 12:53:23 UTC


README

Current Release Build Status Code Coverage Code Climate Test Coverage

Installation

First, install the package via composer:

composer require "djstarcom/laravel-robots-manager"

The package will automatically register itself.

Usage

Delete projects default public/robots.txt

Add the following to your routes file:

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

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

Refer to the RobotsManager.php for API usage.

License

MIT