PHPackages                             maartenstaa/laravel-41-route-caching - 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. [Caching](/categories/caching)
4. /
5. maartenstaa/laravel-41-route-caching

ActiveLibrary[Caching](/categories/caching)

maartenstaa/laravel-41-route-caching
====================================

This package allows you to cache your routes definitions, thereby speeding up each request.

v1.0.3(10y ago)25371.9k↑40.4%11[1 issues](https://github.com/MaartenStaa/laravel-41-route-caching/issues)BSD-3-ClausePHPCI failing

Since Jan 29Pushed 10y ago5 watchersCompare

[ Source](https://github.com/MaartenStaa/laravel-41-route-caching)[ Packagist](https://packagist.org/packages/maartenstaa/laravel-41-route-caching)[ RSS](/packages/maartenstaa-laravel-41-route-caching/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Laravel 4.1 and 4.2 Route Caching
=================================

[](#laravel-41-and-42-route-caching)

This package allows you to cache routes in Laravel 4.1 and 4.2.

[![Build Status](https://camo.githubusercontent.com/cd28982476219c360685aff6284e6fde18949942f7be9a1225c4717fe7a0c342/68747470733a2f2f7472617669732d63692e6f72672f4d61617274656e537461612f6c61726176656c2d34312d726f7574652d63616368696e672e737667)](https://travis-ci.org/MaartenStaa/laravel-41-route-caching)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/53cc85a9d838ef07093aecf050583702b8893876201e7d9014703c1a9201baff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d61617274656e537461612f6c61726176656c2d34312d726f7574652d63616368696e672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/MaartenStaa/laravel-41-route-caching/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/f7faf2991460ca678bc07b4903b01e1789a416c47f3ca1b787257bfc145753d8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d61617274656e537461612f6c61726176656c2d34312d726f7574652d63616368696e672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/MaartenStaa/laravel-41-route-caching/?branch=master)

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

[](#installation)

Using [Composer](http://getcomposer.org/), add the package to your `require` section.

```
{
	"require": {
		"maartenstaa/laravel-41-route-caching": "dev-master"
	}
}
```

Run `composer update`. Next, open up your `app/config/app.php` configuration file and add the service provider at the end of the providers section:

```
return array(
	// ...

	'providers' => array(
		// ...

		'MaartenStaa\Routing\RoutingServiceProvider',

	),

);
```

Usage
-----

[](#usage)

In your `app/routes.php` file, or any other file you use that defines routes, wrap the definition of your routes in a call to `Route::cache` as follows:

```
Route::cache(__FILE__, function() {
	// Define your routes here.
});
```

This package will save the routes defined in the closure, and write them to your cache. On any subsequent requests, it will figure out the closure will not have to be executed, and it will load the routes from your cache instead. Since you're passing it the name of the file that defines the routes (`__FILE__`), the script will automatically detect when the file has been modified. In other words, you do not need to clear your cache after adding a new route.

Why?
----

[](#why)

Through profiling, I found that defining many routes (in my case 100+) took a significant time on each request - time that would have been better spent preparing the response for the user.

Caching these routes significantly reduces overhead.

Limitations
-----------

[](#limitations)

You cannot use this package to serialize routes using a closure, such as this:

```
Route::get('/', function () {
	return 'Hello, world!';
});
```

You can only use it to serialize routes to a controller. If your `app/routes.php`file has both, you can of course put all controller routes in a `cache` call, and any routes that use closures outside of it.

Contributing
------------

[](#contributing)

### Coding standard

[](#coding-standard)

All code is to follow the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) coding standard.

### Unit tests

[](#unit-tests)

If you find a bug, feel free to send a pull request to fix it, but make sure to always include a regression test.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~155 days

Total

4

Last Release

3660d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/33e827509a7fa4b6ad18dfacc6cf7e6c1a6cb58b9b61b83787e0940a371ac70c?d=identicon)[MaartenStaa](/maintainers/MaartenStaa)

---

Top Contributors

[![yuripave](https://avatars.githubusercontent.com/u/315831?v=4)](https://github.com/yuripave "yuripave (3 commits)")[![eelkevdbos](https://avatars.githubusercontent.com/u/1001306?v=4)](https://github.com/eelkevdbos "eelkevdbos (2 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![zandzpider](https://avatars.githubusercontent.com/u/321691?v=4)](https://github.com/zandzpider "zandzpider (1 commits)")

---

Tags

laravelroutesperformancecachecachingroute

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maartenstaa-laravel-41-route-caching/health.svg)

```
[![Health](https://phpackages.com/badges/maartenstaa-laravel-41-route-caching/health.svg)](https://phpackages.com/packages/maartenstaa-laravel-41-route-caching)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[putyourlightson/craft-blitz

Intelligent static page caching for creating lightning-fast sites.

153471.5k29](/packages/putyourlightson-craft-blitz)[silverstripe/staticpublishqueue

Static publishing queue to create static versions of pages for enhanced performance and security

45135.4k4](/packages/silverstripe-staticpublishqueue)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2984.6k1](/packages/alekseykorzun-memcached-wrapper-php)[swiggles/memcache

Memcache driver for Laravel 5

1449.9k1](/packages/swiggles-memcache)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)

PHPackages © 2026

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