PHP code example of healey / robots

1. Go to this page and download the library: Download healey/robots library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

healey / robots example snippets


'Healey\Robots\RobotsServiceProvider',



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, array('Content-Type' => 'text/plain'));
});


use Healey\Robots\Robots;

$robots = new Robots();
$robots->addUserAgent('*');
$robots->addSitemap('sitemap.xml');

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