djstarcom / laravel-robots-manager
Laravel robots.txt manager
Package info
github.com/DJStarCOM/laravel-robots-manager
pkg:composer/djstarcom/laravel-robots-manager
v2.0.1
2021-06-15 07:05 UTC
Requires
- php: >=7.2
- laravel/framework: ~6.20.26|~7.0|~8.0
Requires (Dev)
- phpunit/phpunit: ^6.0 || ^7.0 || ^8.0
- roave/security-advisories: dev-master
- scrutinizer/ocular: dev-master
- squizlabs/php_codesniffer: ^2.4 || ^3.0
This package is auto-updated.
Last update: 2026-03-16 16:49:49 UTC
README
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.