PHPackages                             nystudio107/routemap - 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. nystudio107/routemap

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

nystudio107/routemap
====================

Returns a list of Craft/Vue/React route rules and entry &amp; asset URLs for ServiceWorkers from Craft entries

1.0.0(8y ago)28122[1 PRs](https://github.com/nystudio107/routemap/pulls)PHP

Since Aug 28Pushed 7y ago2 watchersCompare

[ Source](https://github.com/nystudio107/routemap)[ Packagist](https://packagist.org/packages/nystudio107/routemap)[ RSS](/packages/nystudio107-routemap/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

[![No Maintenance Intended](https://camo.githubusercontent.com/d904056147052e22d8e1c7f46bb50293ed2aeb4c43ead9a2d0cf7a48b46d0562/687474703a2f2f756e6d61696e7461696e65642e746563682f62616467652e737667)](http://unmaintained.tech/)

DEPRECATED
==========

[](#deprecated)

This Craft CMS 2.x plugin is no longer supported, but it is fully functional, and you may continue to use it as you see fit. The license also allows you to fork it and make changes as needed for legacy support reasons.

The Craft CMS 3.x version of this plugin can be found here: [craft-routemap](https://github.com/nystudio107/craft-routemap) and can also be installed via the Craft Plugin Store in the Craft CP.

Route Map plugin for Craft CMS
==============================

[](#route-map-plugin-for-craft-cms)

Returns a list of Craft/Vue/React route rules and entry &amp; asset URLs for ServiceWorkers from Craft entries

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

[](#installation)

To install Route Map, follow these steps:

1. Download &amp; unzip the file and place the `routemap` directory into your `craft/plugins` directory
2. -OR- do a `git clone https://github.com/nystudio107/routemap.git` directly into your `craft/plugins` folder. You can then update it with `git pull`
3. -OR- install with Composer via `composer require nystudio107/routemap`
4. Install plugin in the Craft Control Panel under Settings &gt; Plugins
5. The plugin folder should be named `routemap` for Craft to see it. GitHub recently started appending `-master` (the branch name) to the name of the folder for zip file downloads.

Route Map works on Craft 2.4.x and Craft 2.5.x.

Route Map Overview
------------------

[](#route-map-overview)

Route Map is a plugin to help bridge the routing gap between frontend technologies like Vue/React and Craft CMS. Using Route Map, you can define your routes in Craft CMS as usual, and use an XHR to get a list of the routes in JSON format for use in your Vue/React frontend (it converts `blog/{slug}` dynamic routes to `/blog/:slug`).

This allows you to create your routes dynamically in Craft CMS using the AdminCP, and have them translate automatically to your frontend framework of choice.

Route Map also assists with [ServiceWorkers](https://nystudio107.com/blog/service-workers-and-offline-browsing) by providing a list of all of the URLs on your Craft CMS site, or just the specific sections you're interested in. You can limit the URLs returned via any `ElementCriteriaModel` attributes, and Route Map can even return a list of URLs to all of the Assets that a particular Entry uses (whether in Assets fields, or embedded in Matrix/Neo blocks).

This allows you, for instance, to have a ServiceWorker that will automatically pre-cache the latest 5 blog entries on your site, as well as any images displayed on those pages, so that they will work with offline browsing.

Route Map maintains a cache of each requested set of URLs for excellent performance for repeated requests. This cache is automatically cleared whenever entries are created or modified.

Configuring Route Map
---------------------

[](#configuring-route-map)

There's nothing to configure.

Using Route Map via XHR
-----------------------

[](#using-route-map-via-xhr)

### Route Rules

[](#route-rules)

The controller API endpoint `/admin/actions/routeMap/getAllRouteRules` will return all of your website's route rules in an associative array. By default, they are in Craft CMS format (e.g.: `blog/{slug}`):

```
{
  "notFound": {
    "handle": "notFound",
    "type": "single",
    "url": "404",
    "template": "404"
  },
  "blog": {
    "handle": "blog",
    "type": "channel",
    "url": "blog\/{slug}",
    "template": "blog\/_entry"
  },
  "blogIndex": {
    "handle": "blogIndex",
    "type": "single",
    "url": "blog",
    "template": "blog\/index"
  },
  "homepage": {
    "handle": "homepage",
    "type": "single",
    "url": "\/",
    "template": "index"
  }
}

```

The `format` URL parameter allows you to specify either `Craft` | `React` | `Vue` format for your URL routes. For example, the controller API endpoint `/admin/actions/routeMap/getAllRouteRules?format=Vue` will return the same route rules above, but formatted for `Vue` (e.g.: `blog/:slug`):

```
{
  "notFound": {
    "handle": "notFound",
    "type": "single",
    "url": "\/404",
    "template": "404"
  },
  "blog": {
    "handle": "blog",
    "type": "channel",
    "url": "\/blog\/:slug",
    "template": "blog\/_entry"
  },
  "blogIndex": {
    "handle": "blogIndex",
    "type": "single",
    "url": "\/blog",
    "template": "blog\/index"
  },
  "homepage": {
    "handle": "homepage",
    "type": "single",
    "url": "\/",
    "template": "index"
  }
}

```

Note that `blog\/{slug}` was changed to `blog\/:slug`. This allows you to easily map both static and dynamic Craft CMS routes to your router of choice.

If you want just the route rules for a particular section, you can use the controller API endpoint `/admin/actions/routeMap/getSectionRouteRules?section=blog` (note the required `section` parameter that specifies the Section handle you want):

```
{
  "handle": "blog",
  "type": "channel",
  "url": "blog\/{slug}",
  "template": "blog\/_entry"
}

```

You can also pass in the optional `format` parameter to get route rules from a specific section, in a particular format via the controller API endpoint `/admin/actions/routeMap/getSectionRouteRules?section=blog&format=Vue`

```
{
  "handle": "blog",
  "type": "channel",
  "url": "blog\/:slug",
  "template": "blog\/_entry"
}

```

### Entry URLs

[](#entry-urls)

The controller API endpoint `/admin/actions/routeMap/getAllUrls` will return a list of *all* of the URLs to all of the Entries on your website:

```
[
  "http:\/\/nystudio107.dev\/404",
  "http:\/\/nystudio107.dev\/blog\/a-gulp-workflow-for-frontend-development-automation",
  "http:\/\/nystudio107.dev\/blog\/making-websites-accessible-americans-with-disabilities-act-ada",
  "http:\/\/nystudio107.dev\/blog\/static-caching-with-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/the-case-of-the-missing-php-session",
  "http:\/\/nystudio107.dev\/blog\/so-you-wanna-make-a-craft-3-plugin",
  "http:\/\/nystudio107.dev\/blog\/a-b-split-testing-with-nginx-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/mobile-testing-local-dev-sharing-with-homestead",
  "http:\/\/nystudio107.dev\/blog\/simple-static-asset-versioning",
  "http:\/\/nystudio107.dev\/blog\/tags-gone-wild",
  "http:\/\/nystudio107.dev\/blog\/local-development-with-vagrant-homestead",
  "http:\/\/nystudio107.dev\/blog\/mitigating-disaster-via-website-backups",
  "http:\/\/nystudio107.dev\/blog\/web-hosting-for-agencies-freelancers",
  "http:\/\/nystudio107.dev\/blog\/implementing-critical-css",
  "http:\/\/nystudio107.dev\/blog\/autocomplete-search-with-the-element-api-vuejs",
  "http:\/\/nystudio107.dev\/blog\/json-ld-structured-data-and-erotica",
  "http:\/\/nystudio107.dev\/blog\/craft-3-beta-executive-summary",
  "http:\/\/nystudio107.dev\/blog\/prevent-google-from-indexing-staging-sites",
  "http:\/\/nystudio107.dev\/blog\/loadjs-as-a-lightweight-javascript-loader",
  "http:\/\/nystudio107.dev\/blog\/creating-a-content-builder-in-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/service-workers-and-offline-browsing",
  "http:\/\/nystudio107.dev\/blog\/using-phpstorm-with-vagrant-homestead",
  "http:\/\/nystudio107.dev\/blog\/frontend-dev-best-practices-for-2017",
  "http:\/\/nystudio107.dev\/blog\/using-systemjs-as-javascript-loader",
  "http:\/\/nystudio107.dev\/blog\/a-better-package-json-for-the-frontend",
  "http:\/\/nystudio107.dev\/blog\/modern-seo-snake-oil-vs-substance",
  "http:\/\/nystudio107.dev\/blog\/lazy-loading-with-the-element-api-vuejs",
  "http:\/\/nystudio107.dev\/blog\/installing-mozjpeg-on-ubuntu-16-04-forge",
  "http:\/\/nystudio107.dev\/blog\/a-pretty-website-isnt-enough",
  "http:\/\/nystudio107.dev\/blog\/using-vuejs-2-0-with-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/image-optimization-project-results",
  "http:\/\/nystudio107.dev\/blog\/database-asset-syncing-between-environments-in-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/hardening-craft-cms-permissions",
  "http:\/\/nystudio107.dev\/blog\/multi-environment-config-for-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/google-amp-should-you-care",
  "http:\/\/nystudio107.dev\/blog\/creating-optimized-images-in-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/the-craft-cache-tag-in-depth",
  "http:\/\/nystudio107.dev\/blog\/twig-processing-order-and-scope",
  "http:\/\/nystudio107.dev\/blog\/stop-using-htaccess-files-no-really",
  "http:\/\/nystudio107.dev\/blog",
  "http:\/\/nystudio107.dev\/"
]

```

You can retrieve just the entries for a particular section via the controller API endpoint `/admin/actions/routeMap/getSectionUrls?section=blog` (note the required `section` parameter that specifies the Section handle you want):

```
[
  "http:\/\/nystudio107.dev\/blog\/a-gulp-workflow-for-frontend-development-automation",
  "http:\/\/nystudio107.dev\/blog\/making-websites-accessible-americans-with-disabilities-act-ada",
  "http:\/\/nystudio107.dev\/blog\/static-caching-with-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/the-case-of-the-missing-php-session",
  "http:\/\/nystudio107.dev\/blog\/so-you-wanna-make-a-craft-3-plugin",
  "http:\/\/nystudio107.dev\/blog\/a-b-split-testing-with-nginx-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/mobile-testing-local-dev-sharing-with-homestead",
  "http:\/\/nystudio107.dev\/blog\/simple-static-asset-versioning",
  "http:\/\/nystudio107.dev\/blog\/tags-gone-wild",
  "http:\/\/nystudio107.dev\/blog\/local-development-with-vagrant-homestead",
  "http:\/\/nystudio107.dev\/blog\/mitigating-disaster-via-website-backups",
  "http:\/\/nystudio107.dev\/blog\/web-hosting-for-agencies-freelancers",
  "http:\/\/nystudio107.dev\/blog\/implementing-critical-css",
  "http:\/\/nystudio107.dev\/blog\/autocomplete-search-with-the-element-api-vuejs",
  "http:\/\/nystudio107.dev\/blog\/json-ld-structured-data-and-erotica",
  "http:\/\/nystudio107.dev\/blog\/craft-3-beta-executive-summary",
  "http:\/\/nystudio107.dev\/blog\/prevent-google-from-indexing-staging-sites",
  "http:\/\/nystudio107.dev\/blog\/loadjs-as-a-lightweight-javascript-loader",
  "http:\/\/nystudio107.dev\/blog\/creating-a-content-builder-in-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/service-workers-and-offline-browsing",
  "http:\/\/nystudio107.dev\/blog\/using-phpstorm-with-vagrant-homestead",
  "http:\/\/nystudio107.dev\/blog\/frontend-dev-best-practices-for-2017",
  "http:\/\/nystudio107.dev\/blog\/using-systemjs-as-javascript-loader",
  "http:\/\/nystudio107.dev\/blog\/a-better-package-json-for-the-frontend",
  "http:\/\/nystudio107.dev\/blog\/modern-seo-snake-oil-vs-substance",
  "http:\/\/nystudio107.dev\/blog\/lazy-loading-with-the-element-api-vuejs",
  "http:\/\/nystudio107.dev\/blog\/installing-mozjpeg-on-ubuntu-16-04-forge",
  "http:\/\/nystudio107.dev\/blog\/a-pretty-website-isnt-enough",
  "http:\/\/nystudio107.dev\/blog\/using-vuejs-2-0-with-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/image-optimization-project-results",
  "http:\/\/nystudio107.dev\/blog\/database-asset-syncing-between-environments-in-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/hardening-craft-cms-permissions",
  "http:\/\/nystudio107.dev\/blog\/multi-environment-config-for-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/google-amp-should-you-care",
  "http:\/\/nystudio107.dev\/blog\/creating-optimized-images-in-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/the-craft-cache-tag-in-depth",
  "http:\/\/nystudio107.dev\/blog\/twig-processing-order-and-scope",
  "http:\/\/nystudio107.dev\/blog\/stop-using-htaccess-files-no-really"
]

```

Both of the above controller API endpoints support an optional `attributes` parameter that lets you pass in an array of `ElementCriteriaModel` attribute key/value pairs to be used to refine the Entries selected.

For instance, if you wanted just the most recent 5 Entries from the `blog` section, you'd use the controller API endpoint `/admin/actions/routeMap/getSectionUrls?section=blog&attributes[limit]=5`:

```
[
  "http:\/\/nystudio107.dev\/blog\/a-gulp-workflow-for-frontend-development-automation",
  "http:\/\/nystudio107.dev\/blog\/making-websites-accessible-americans-with-disabilities-act-ada",
  "http:\/\/nystudio107.dev\/blog\/static-caching-with-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/the-case-of-the-missing-php-session",
  "http:\/\/nystudio107.dev\/blog\/so-you-wanna-make-a-craft-3-plugin"
]

```

Or if you wanted the 5 oldest Entries from the `blog` section, you'd use the controller API endpoint `/admin/actions/routeMap/getSectionUrls?section=blog&attributes[limit]=5&attributes[order]=postDate asc`:

```
[
  "http:\/\/nystudio107.dev\/blog\/stop-using-htaccess-files-no-really",
  "http:\/\/nystudio107.dev\/blog\/twig-processing-order-and-scope",
  "http:\/\/nystudio107.dev\/blog\/the-craft-cache-tag-in-depth",
  "http:\/\/nystudio107.dev\/blog\/creating-optimized-images-in-craft-cms",
  "http:\/\/nystudio107.dev\/blog\/google-amp-should-you-care"
]

```

### Entry URL Assets

[](#entry-url-assets)

The controller API endpoint `/admin/actions/routeMap/getUrlAssetUrls?url=/blog/tags-gone-wild` will return all of the image Assets from the Entry with the URI of `/blog/tags-gone-wild`, whether in Assets fields, or embedded in Matrix/Neo blocks (note the required `url` parameter that specifies the URL to the entry you want):

```
[
  "http:\/\/nystudio107.dev\/img\/blog\/buried-in-tag-manager-tags.jpg",
  "http:\/\/nystudio107.dev\/img\/blog\/they-told-two-friends.png",
  "http:\/\/nystudio107.dev\/img\/blog\/tag-manager-tags-gone-wild.png",
  "http:\/\/nystudio107.dev\/img\/blog\/google-chrome-activity-indicator.png",
  "http:\/\/nystudio107.dev\/img\/blog\/tag-javascript-executing.png",
  "http:\/\/nystudio107.dev\/img\/blog\/tags-are-prescription-drugs.jpg",
  "http:\/\/nystudio107.dev\/img\/blog\/taming-tags-whip.jpg"
]

```

Either a full URL or a partial URI can be passed in via the `url` parameter.

By default, it only returns Assets of the type `image` but using the optional parameter `assetTypes` you can pass in an array of the types of Assets you want returned. For instance, if we wanted `image`, `video`, and `pdf` Assets returned, we'd use the controller API endpoint `/admin/actions/routeMap/getUrlAssetUrls?url=/blog/tags-gone-wild&assetTypes[0]=image&assetTypes[1]=video&assetTypes[2]=pdf'`.

Using Route Map in your Twig Templates
--------------------------------------

[](#using-route-map-in-your-twig-templates)

You can also access any of the aforementioned functionality from within Craft CMS Twig templates.

### Route Rules

[](#route-rules-1)

To get all of your website's route rules:

```
{% set routeRules = craft.routeMap.getAllRouteRules() %}

```

To specify the format that the route rules should be returned in, pass in either `Craft` | `React` | `Vue`:

```
{% set routeRules = craft.routeMap.getAllRouteRules('Vue') %}

```

To get route rules from only a specific section (such as `blog`, in this case), pass in the Section handle:

```
{% set routeRules = craft.routeMap.getSectionRouteRules('blog') %}

```

You can also pass in the optional `format` parameter to get route rules from a specific section, in a particular format:

```
{% set routeRules = craft.routeMap.getSectionRouteRules('blog', 'Vue') %}

```

### Entry URLs

[](#entry-urls-1)

To get all of your website's public Entry URLs:

```
{% set urls = craft.routeMap.getAllUrls() %}

```

To refine the URLs returned, you can pass in optional `ElementCriteriaModel` attributes via key/value pairs:

```
{% set urls = craft.routeMap.getAllUrls({'limit': 5}) %}

```

or

```
{% set urls = craft.routeMap.getAllUrls({'limit': 5, 'order': 'postDate asc'}) %}

```

To get URLs from just a specific Section:

```
{% set urls = craft.routeMap.getSectionUrls('blog') %}

```

To refine the URLs returned, you can pass in optional `ElementCriteriaModel` attributes via key/value pairs:

```
{% set urls = craft.routeMap.getSectionUrls('blog', {'limit': 5}) %}

```

or

```
{% set urls = craft.routeMap.getSectionUrls('blog', {'limit': 5, 'order': 'postDate asc'}) %}

```

### Entry URL Assets

[](#entry-url-assets-1)

To get all of the Asset URLs in a particular Entry (whether in Assets fields or embedded in Matrix/Neo blocks) by passing in a URL or URI to the entry:

```
{% set urls = craft.routeMap.getUrlAssetUrls('/blog/tags-gone-wild') %}

```

By default, it returns only Assets of the type `image`. You can pass in an optional array of Asset types you want returned:

```
{% set urls = craft.routeMap.getUrlAssetUrls('/blog/tags-gone-wild', ['image', 'video', 'pdf']) %}

```

Using Route Map from your Plugins
---------------------------------

[](#using-route-map-from-your-plugins)

The `craft()->routeMap` service gives you access to all of the functions mentioned above via your plugins.

### Route Rules

[](#route-rules-2)

To get all of your website's route rules:

```
$routeRules = craft()->routeMap->getAllRouteRules();

```

To specify the format that the route rules should be returned in, pass in either `Craft` | `React` | `Vue`:

```
$routeRules = craft()->routeMap->getAllRouteRules('Vue');

```

To get route rules from only a specific section (such as `blog`, in this case), pass in the Section handle:

```
$routeRules = craft()->routeMap->getSectionRouteRules('blog');

```

You can also pass in the optional `format` parameter to get route rules from a specific section, in a particular format:

```
$routeRules = craft()->routeMap->getSectionRouteRules('blog', 'Vue');

```

### Entry URLs

[](#entry-urls-2)

To get all of your website's public Entry URLs:

```
$urls = craft()->routeMap->getAllUrls();

```

To refine the URLs returned, you can pass in optional `ElementCriteriaModel` attributes via key/value pairs:

```
$urls = craft()->routeMap->getAllUrls(array('limit' => 5));

```

or

```
$urls = craft()->routeMap->getAllUrls(array('limit' => 5, 'order' => 'postDate asc'));

```

To get URLs from just a specific Section:

```
$urls = craft()->routeMap->getSectionUrls('blog');

```

To refine the URLs returned, you can pass in optional `ElementCriteriaModel` attributes via key/value pairs:

```
$urls = craft()->routeMap->getSectionUrls('blog', array('limit' => 5));

```

or

```
$urls = craft()->routeMap->getSectionUrls('blog', array('limit' => 5, 'order' => 'postDate asc'));

```

### Entry URL Assets

[](#entry-url-assets-2)

To get all of the Asset URLs in a particular Entry (whether in Assets fields or embedded in Matrix/Neo blocks) by passing in a URL or URI to the entry:

```
$urls = craft()->routeMap->getUrlAssetUrls('/blog/tags-gone-wild');

```

By default, it returns only Assets of the type `image`. You can pass in an optional array of Asset types you want returned:

```
$urls = craft()->routeMap->getUrlAssetUrls('/blog/tags-gone-wild', array('image', 'video', 'pdf'));

```

Route Map Roadmap
-----------------

[](#route-map-roadmap)

Some things to do, and ideas for potential features:

- Add support for Category Groups / Category URLs
- Add support for Commerce Products / Variant URLs
- Add support for multiple locales

Brought to you by [nystudio107](https://nystudio107.com)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Unknown

Total

1

Last Release

3227d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7570798?v=4)[Andrew Welch](/maintainers/khalwat)[@khalwat](https://github.com/khalwat)

---

Top Contributors

[![khalwat](https://avatars.githubusercontent.com/u/7570798?v=4)](https://github.com/khalwat "khalwat (18 commits)")

---

Tags

craft-plugincraftcmsreactroutesserviceworkervue

### Embed Badge

![Health badge](/badges/nystudio107-routemap/health.svg)

```
[![Health](https://phpackages.com/badges/nystudio107-routemap/health.svg)](https://phpackages.com/packages/nystudio107-routemap)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[mautic/core

Mautic Open Source Distribution

9.8k2.6k9](/packages/mautic-core)[mediawiki/maps

Adds various mapping features to MediaWiki

78149.7k3](/packages/mediawiki-maps)[rainlab/blog-plugin

Blog plugin for October CMS

17158.6k](/packages/rainlab-blog-plugin)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

19246.3k2](/packages/civicrm-civicrm-drupal-8)[starcitizentools/citizen-skin

A beautiful, usable, responsive MediaWiki skin with in-depth extension support. Originally developed for the Star Citizen Wiki.

3355.8k](/packages/starcitizentools-citizen-skin)

PHPackages © 2026

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