2017 © Pedro Peláez
 

library larasitemap

A simple sitemap generator for Laravel.

image

fuxu/larasitemap

A simple sitemap generator for Laravel.

  • Monday, March 12, 2018
  • by fuxu
  • Repository
  • 2 Watchers
  • 2 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

LaraSitemap

A very simple sitemap generator for Laravel 5 following Sitemaps XML format, (*1)

Installation

composer require fuxu/larasitemap

Register

Add the following line to array providers in config/app.php, (*2)

FuXu\LaraSitemap\SitemapServiceProvider::class,

API

Sitemap

void add(string $loc, string $lastmod, double $priority, string $changefreq)
Type Parameter Description
string $loc required URL of the page. This URL must begin with the protocol (such as http) and end with a trailing slash, if your web server requires it. This value must be less than 2,048 characters.
string $lastmod optional The date of last modification of the file. This date should be in W3C Datetime format. This format allows you to omit the time portion, if desired, and use YYYY-MM-DD. Note that this tag is separate from the If-Modified-Since (304) header the server can return, and search engines may use the information from both sources differently.
double $priority optional The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.
string $changefreq optional How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page. Valid values are: always, hourly, daily, weekly, monthly, yearly, never.
Response render($format)
Type Parameter Description
string $format optional The output format. The default value is urlset. Valid values are: urlset, sitemapindex.

Example

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;

use FuXu\LaraSitemap\Sitemap;

class SitemapController extends BaseController
{
    public function __construct(Sitemap $sitemap)
    {
        $this->sitemap = $sitemap;
    }

    /**
     * Generate sitemapindex format
     *
     */
    public function index(Request $request)
    {
        $this->sitemap->add(URL::to('sitemap/urlset'));

        return $this->sitemap->render('sitemapindex');
    }

    /**
     * Generate urlset format
     *
     */

    public function urlset(Request $request)
    {
        $this->sitemap->add(URL::to('welcome'));

        return $this->sitemap->render();
    }

}

The Versions

12/03 2018

dev-master

9999999-dev

A simple sitemap generator for Laravel.

  Sources   Download

MIT

The Requires

 

by Fu Xu

12/03 2018

v0.1.2

0.1.2.0

A simple sitemap generator for Laravel.

  Sources   Download

MIT

The Requires

 

by Fu Xu

13/01 2018

v0.1.1

0.1.1.0

A simple sitemap generator for Laravel.

  Sources   Download

MIT

The Requires

 

by Fu Xu

15/06 2017

v0.1.0

0.1.0.0

A simple sitemap generator for Laravel.

  Sources   Download

MIT

by Fu Xu