PHPackages                             nzm/amp-cache-url - 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. nzm/amp-cache-url

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

nzm/amp-cache-url
=================

Composer package for generating AMP Cache URLs

1.0.1(2y ago)09MITPHP

Since May 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/nzmacat/amp-cache-url)[ Packagist](https://packagist.org/packages/nzm/amp-cache-url)[ RSS](/packages/nzm-amp-cache-url/feed)WikiDiscussions main Synced 1mo ago

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

AmpCacheUrl PHP Library
=======================

[](#ampcacheurl-php-library)

This PHP library provides a class called `Generator` that allows you to generate cache URLs for the AMP Cache. It is inspired by the `@ampproject/toolbox-cache-url` library in Node.js.

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

[](#installation)

You can install this library using Composer. Run the following command:

```
composer require nzm/amp-cache-url

```

Usage
-----

[](#usage)

Here's an example of how to use the `Generator` class:

```
use Nzm\AmpCacheUrl\Generator;
use Nzm\AmpCacheUrl\ServingMode;

$generator = new Generator();
$domainSuffix = 'cdn.ampproject.org';
$url = 'https://example.com/amp/page.html';
$servingMode = ServingMode::Content;

$cacheUrl = $generator->Generate($domainSuffix, $url, $servingMode);

echo $cacheUrl;
```

This will output the cache URL for the provided URL and serving mode.

### URL Generation

[](#url-generation)

The `Generate` method in the `Generator` class takes the domain suffix, the URL, and an optional serving mode as parameters and returns the cache URL for the given input. It handles the necessary encoding and formatting of the URL.

Credits
-------

[](#credits)

This library is an implementation of the `@ampproject/toolbox-cache-url` library in Node.js. You can find the original Node.js library [here](https://github.com/ampproject/amp-toolbox.git).

License
-------

[](#license)

This library is released under the [MIT License](LICENSE).

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Total

2

Last Release

1088d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dbba47aef5a0b3b8227555f65a34e647f71cb4e29f8ad452408b5454883ead95?d=identicon)[nzmacat](/maintainers/nzmacat)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nzm-amp-cache-url/health.svg)

```
[![Health](https://phpackages.com/badges/nzm-amp-cache-url/health.svg)](https://phpackages.com/packages/nzm-amp-cache-url)
```

###  Alternatives

[liyunfang/yii2-contextmenu

yii2 Extended for bootstrap-contextmenu plugin https://github.com/sydcanem/bootstrap-contextmenu

2432.4k1](/packages/liyunfang-yii2-contextmenu)[danielgsims/staticproxy

A thin proxy for static classes

118.2k](/packages/danielgsims-staticproxy)

PHPackages © 2026

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