PHP code example of fuelviews / laravel-robots-txt

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

    

fuelviews / laravel-robots-txt example snippets


namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;

class Post extends Model implements Sitemapable {
    /**
     * Convert the Post model instance into a sitemap URL entry.
     *
     * @return \Spatie\Sitemap\Tags\Url
     */
    public function toSitemapUrl() {
        $url = Url::create(url("{$this->id}"))
            ->setLastModificationDate($this->updated_at)
            ->setChangeFrequency('daily')
            ->setPriority(0.8);

        return $url;
    }
}
bash
php artisan vendor:publish --provider="Fuelviews\Sitemap\SitemapServiceProvider" --tag="sitemap-config"
bash
php artisan sitemap:generate