PHP code example of spatie / robots-txt

1. Go to this page and download the library: Download spatie/robots-txt 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/ */

    

spatie / robots-txt example snippets

 php
$robots = Spatie\Robots\Robots::create();

$robots->mayIndex('https://www.spatie.be/nl/admin');

$robots->mayFollowOn('https://www.spatie.be/nl/admin');
 php
$robots = Spatie\Robots\Robots::create('UserAgent007');
 php
$robots = Spatie\Robots\Robots::create()
    ->withTxt('https://www.spatie.be/robots-custom.txt');

$robots = Spatie\Robots\Robots::create()
    ->withTxt(__DIR__ . '/public/robots.txt');