PHPackages                             ash/monal-sitemap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ash/monal-sitemap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ash/monal-sitemap
=================

Sitemap generator for Monal CMS.

0.1.1(11y ago)038MITPHPPHP &gt;=5.3.0

Since Jun 30Pushed 11y ago1 watchersCompare

[ Source](https://github.com/juice49/Monal-Sitemap)[ Packagist](https://packagist.org/packages/ash/monal-sitemap)[ RSS](/packages/ash-monal-sitemap/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (4)Used By (0)

Monal Sitemap
=============

[](#monal-sitemap)

Sitemap generator for [Monal CMS](https://github.com/arranjacques/monal). Allows the registering of entities on a package by package basis.

By default Monal Sitemap places sitemaps at `sitemap` and `sitemap.xml`. This name can be customised via the `config['filename']` option.

Installation
------------

[](#installation)

1. Add `ash\monal-sitemap` as a Composer dependency and install
2. Add `'Ash\MonalSitemap\MonalSitemapServiceProvider'` to app providers
3. Add `'Sitemap' => 'Ash\MonalSitemap\Facades\Sitemap'` to app aliases

Registering a sitemap section
-----------------------------

[](#registering-a-sitemap-section)

Monal Sitemap consists of collections of entities. An entity can be either a single entity (a `SitemapEntity`) or a collection of entities (a `SitemapCollection`).

Entities are registered using the `register` function.

### Sitemap::register( string $name, Callable $register \[, $cache \] )

[](#sitemapregister-string-name-callable-register--cache--)

#### $name

[](#name)

The name of the collection / entity. Must be unique.

#### $register

[](#register)

A function that returns either an instance of `SitemapCollection` or `SitemapEntity`.

#### $cache

[](#cache)

Override the default cache (1440 minutes). Set to either a custom number of minutes, or `false` to disable caching.

### SitemapEntity and SitemapCollection

[](#sitemapentity-and-sitemapcollection)

`SitemapEntity` and `SitemapCollection` are identical in all regards other than `SitemapCollection`s ability to contain a collection of entities.

#### $entity/$collection-&gt;uri - required

[](#entitycollection-uri---required)

Full URI of the entity (excluding domain).

#### $entity/$collection-&gt;name - required

[](#entitycollection-name---required)

#### $entity/$collection-&gt;lastmod

[](#entitycollection-lastmod)

#### $entity/$collection-&gt;changefreq

[](#entitycollection-changefreq)

#### $entity/$collection-&gt;priority

[](#entitycollection-priority)

#### $collection-&gt;add($collection/$entity)

[](#collection-addcollectionentity)

Add a collection or entity to the collection. Can be chained or given an array, for example:

```
$collection
	->add($subCollection)
	->add($subCollection2);

$collection->add([
	$subCollection,
	$subCollection2
]);

```

Example
-------

[](#example)

```
// Register a collection named 'products'

Sitemap::register('products', function($uri) {

	// The second param of the register function is a callback
// that should return a collection or an entity

	// Create a new collection
	$collection = App::make('SitemapCollection');

	// Set the collection URI
	// $uri passed to this callback is the same as the collection name (products)
	$collection->uri = $uri;

	$collection->name = 'Products';

	// Gather data for a resource
	foreach(Product::all() as $product) {

		// Create a new single entity
		$entity = App::make('SitemapEntity');

		// Set entity URI
		$entity->uri = 'products/' . $product->uri;

		$entity->name = $product->name;

		// Set entity lastmod
		// The default Laravel updated_at timestamp works here
		$entity->lastmod = $product->updated_at;

		// Add the single entity to the collection
		$collection->add($entity);

	}

	return $collection;

});

```

Templating
----------

[](#templating)

The sitemap uses a view called `sitemap.blade.php` that you can publish to your local view directory in order to customise. The sitemap object is passed to the view as `$sitemap`.

You can either iterate through the collections and entities manually, or use the `$sitemap->html()` function to output a `` containing the sitemap.

Iterating through the sitemap to create a custom output is very simple, see the use of Blade's `@each` function in the default view.

Todo
----

[](#todo)

- Should / could this be a generic Laravel tool, rather than being *for* Monal?
- Add entity validation - `$entity->valid()` is checked upon adding, currently always returns true
- Unit tests
- Add default cache duration as config item
- Implement gzipping of XML version

Releases
--------

[](#releases)

### 0.1.1 - 09/07/14

[](#011---090714)

- Fix XML output

### 0.1.0 - 02/07/14

[](#010---020714)

- Improved HTML templating (now uses a Blade view that can be published to the local views dir)

### 0.0.1 - 01/07/14

[](#001---010714)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

3

Last Release

4325d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25134?v=4)[Andrew Shitov](/maintainers/Ash)[@ash](https://github.com/ash)

---

Top Contributors

[![juice49](https://avatars.githubusercontent.com/u/1454914?v=4)](https://github.com/juice49 "juice49 (6 commits)")

### Embed Badge

![Health badge](/badges/ash-monal-sitemap/health.svg)

```
[![Health](https://phpackages.com/badges/ash-monal-sitemap/health.svg)](https://phpackages.com/packages/ash-monal-sitemap)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
