PHPackages                             frankfoerster/cakephp-asset - 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. frankfoerster/cakephp-asset

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

frankfoerster/cakephp-asset
===========================

Provides a CakePHP 3.x AssetHelper to selectively add last modified timestamps to css and js assets.

3.4.0(8y ago)22.5k11MITPHPPHP &gt;=7.0.0

Since May 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/frankfoerster/cakephp-asset)[ Packagist](https://packagist.org/packages/frankfoerster/cakephp-asset)[ Docs](https://github.com/frankfoerster/cakephp-asset)[ RSS](/packages/frankfoerster-cakephp-asset/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (5)Dependencies (3)Versions (10)Used By (1)

cakephp-asset
=============

[](#cakephp-asset)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![Build Status](https://camo.githubusercontent.com/95381ad69dedec7c4f760e3a429e00b8f9ccf7b2ec2ff30c61a025b96215e616/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6672616e6b666f6572737465722f63616b657068702d61737365742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/frankfoerster/cakephp-asset)[![Coverage Status](https://camo.githubusercontent.com/2f3f218dbf37ab92bedbda0cb54203296e05ae2d9a5877c505784ee322ae94a5/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6672616e6b666f6572737465722f63616b657068702d61737365742e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/frankfoerster/cakephp-asset)[![Total Downloads](https://camo.githubusercontent.com/bf163a7834438a3630d78c44b7052fb82c46fc57471e46bacb856f6627037548/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6672616e6b666f6572737465722f63616b657068702d61737365742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/frankfoerster/cakephp-asset)[![Latest Stable Version](https://camo.githubusercontent.com/7d5366e6a91e886897e3bfe7143892a570f1bcc4233138d7538a1dd2cfd91230/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6672616e6b666f6572737465722f63616b657068702d61737365742e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/frankfoerster/cakephp-asset)

1. Provides a CakePHP 3.x AssetHelper to selectively add last modified timestamps to css and js assets. CakePHP's implementation of Asset timestamps does not allow you to apply the behavior selectively to single files. Therefore I created this little Helper.
2. Provides a CakePHP 3.x AssetFilter to request asset files from `/src/Assets/*`. For example if you delevop an app using requirejs, then you can enable the AssetFilter to request modules from `/src/Assets/js/*`. This enables you to hide your source files from the webroot of your application or plugin.

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

Run the following command

```
composer require frankfoerster/cakephp-asset
```

Configuration
-------------

[](#configuration)

You can load the plugin using the shell command:

```
bin/cake plugin load FrankFoerster/Asset

```

Or you can manually add the loading statement in the **config/boostrap.php** file of your application:

```
Plugin::load('FrankFoerster/Asset');
```

Load the Helper
---------------

[](#load-the-helper)

Load the AssetHelper in the **src/View/AppView.php** file of your application.

```
...
public function initialize()
{
    $this->loadHelper('Asset', [
        'className' => 'FrankFoerster/Asset.Asset'
    ]);
}
...
```

Use the AssetHelper in your Layout.
-----------------------------------

[](#use-the-assethelper-in-your-layout)

The last modified time of the asset files is automatically appended.

The methods provided are `AssetHelper::css()` and `AssetHelper::js()`. Both take up to three arguments:

1. `$path` - The path to the asset relative to the webroot of your app or plugin.
2. `$plugin` - Either false to link to an app asset, or the name of a plugin. (default false)
3. `$appendTimestamp` - Whether to append a last modified timestamp to the url. (default true)

### CSS

[](#css)

Linking the CSS file **your\_app/webroot/css/app.css**

```
echo $this->Asset->css('css/app.css');
```

produces the following output:

```

```

### JS

[](#js)

Linking the JS file **your\_app/webroot/js/app.js**

```
echo $this->Asset->js('js/app.js');
```

produces the following output:

```

```

### Linking Plugin Assets

[](#linking-plugin-assets)

Linking the JS file **MyPlugin/webroot/js/plugin.js**

```
echo $this->Asset->js('js/plugin.js', 'MyPlugin');
```

produces the following output:

```

```

### Linking Source Assets

[](#linking-source-assets)

To request assets from `/src/Assets/*` you have to enable the AssetFilter in `config/bootstrap.php`:

```
DispatcherFactory::add('FrankFoerster/Asset.Asset');
```

Then you can use the AssetHelper to request a source asset.

#### App

[](#app)

Linking the JS file **your\_app/src/Assets/js/app.js**

```
echo $this->Asset->js('ASSETS/js/app.js');
```

produces the following output:

```

```

and the AssetFilter will then return the content of **your\_app/src/Assets/js/app.js**.

#### Plugin

[](#plugin)

Linking the JS file **MyPlugin/src/Assets/js/plugin.js**

```
echo $this->Asset->js('ASSETS/js/plugin.js', 'MyPlugin);
```

will procude the following output:

```

```

and the AssetFilter will then return the content of **MyPlugin/src/Assets/js/plugin.js**.

#### Important!

[](#important)

Linking of source assets is only enabled for Configure `'debug' => true`.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

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

Every ~158 days

Total

5

Last Release

3060d ago

PHP version history (2 changes)3.0.0PHP &gt;=5.5.9

3.2.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e283cec64599004f56a995fa747ed73a01870b4131e73a62cbcdfc90db1109c?d=identicon)[frankfoerster](/maintainers/frankfoerster)

---

Top Contributors

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

---

Tags

helpercakephpassetstimestamp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/frankfoerster-cakephp-asset/health.svg)

```
[![Health](https://phpackages.com/badges/frankfoerster-cakephp-asset/health.svg)](https://phpackages.com/packages/frankfoerster-cakephp-asset)
```

###  Alternatives

[markstory/asset_compress

An asset compression plugin for CakePHP. Provides file concatenation and a flexible filter system for preprocessing and minification.

3701.1M15](/packages/markstory-asset-compress)[markstory/mini-asset

An asset compression library. Provides file concatenation and a flexible filter system for preprocessing and minification.

63770.7k3](/packages/markstory-mini-asset)[drmonkeyninja/cakephp-social-share

CakePHP helper for creating social share/bookmark links

31103.5k](/packages/drmonkeyninja-cakephp-social-share)[ishanvyas22/asset-mix

Asset Mix plugin for CakePHP

3376.4k2](/packages/ishanvyas22-asset-mix)[dereuromark/cakephp-url-cache

CakePHP plugin to speed up URL reverse lookup

24117.2k](/packages/dereuromark-cakephp-url-cache)[dereuromark/cakephp-calendar

A CakePHP plugin to easily create calendars.

1674.7k1](/packages/dereuromark-cakephp-calendar)

PHPackages © 2026

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