PHPackages                             h4kuna/assets - 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. h4kuna/assets

Abandoned → [68publishers/asset](/?search=68publishers%2Fasset)Library[Utility &amp; Helpers](/categories/utility)

h4kuna/assets
=============

Support mtime for assets on development machine.

v1.1.0(4y ago)732.9k—7.1%2MITPHP

Since Apr 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/h4kuna/assets)[ Packagist](https://packagist.org/packages/h4kuna/assets)[ Docs](https://github.com/h4kuna/assets)[ RSS](/packages/h4kuna-assets/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (9)Used By (0)

Abandoned
=========

[](#abandoned)

try [68publishers/asset](//github.com/68publishers/asset)

[![Build Status](https://camo.githubusercontent.com/05889d282bdb682ad69aadbb97379c5cbd3b654427050ee7ea6c932d4c542d57/68747470733a2f2f7472617669732d63692e6f72672f68346b756e612f6173736574732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/h4kuna/assets)[![Downloads this Month](https://camo.githubusercontent.com/151056848e5b9b6e6f0834c8b823d66915d0d038f7560105aaf6cad233ed7dce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f68346b756e612f6173736574732e737667)](https://packagist.org/packages/h4kuna/assets)[![Latest stable](https://camo.githubusercontent.com/b04d74cbd97de05dfee8c387533393aff5d9b4e0c4fcf6f79dbd3b7d4b96fe64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68346b756e612f6173736574732e737667)](https://packagist.org/packages/h4kuna/assets)[![Coverage Status](https://camo.githubusercontent.com/2819dcab02ec95a8ffce9ccce752b69f88711c5cd1685c459b96d0275e094e1b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f68346b756e612f6173736574732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/h4kuna/assets?branch=master)

If you need the browser to automatically invalid it's cache, use this extension.

Install via composer:

```
$ composer require h4kuna/assets
```

Changelog
=========

[](#changelog)

- 1.1.0 nothing required, update nette 3.0
- 1.0.0 supports PHP 7.1+ (strict types)
- 0.1.4 0.1.5 newer versions support PHP of version 5.6 and higher
- 0.1.3 supports PHP 5.3

How to use
==========

[](#how-to-use)

For first step you only need to register the extension, other parameters are optional. You have available the new filter **asset** automatically.

```
extensions:
	assets: h4kuna\Assets\DI\AssetsExtension

assets:
    # required nothing

    # optional
    wwwDir: %wwwDir%
    debugMode: %debugMode%
    tempDir: %tempDir%
    wwwTempDir: %wwwDir%/temp # here is place where move assets from 3rd library (from vendor/ etc.)
    externalAssets:
        - %appDir%/../vendor/nette/nette.js # save to %wwwTempDir%/nette.js
        'ext/nette2.4.js': %appDir%/../vendor/nette/nette.js # save to %wwwTempDir%/ext/nette2.4.js

        # download from external source, this is experimental!
        - http://example.com/foo.js # save to %wwwTempDir%/foo.js
        'sha256-secure-token': http://example.com/foo.js # check if is right file
```

### Advantages:

[](#advantages)

- $basePath is not needed
- path is relative to your wwwDir
- cache is built when new file found, or if you remove %tempDir%/cache/\_assets
- behavior is the same in production and development environment

```

```

Example output: `?file mtime`.

```

```

Printing absolute path to the template can be anabled using double slash:

```

```

### Assets

[](#assets)

Here is an object that can have dependency anything and collect css and js files for render to template.

```
/* @var $assets \h4kuna\Assets\Assets */
$assets->addJs('ext/nette2.4.js', ['async' => TRUE]);
echo (string) $assets->renderJs();
```

render this

```

```

### Custom cache builder - advanced usege

[](#custom-cache-builder---advanced-usege)

This creates the cache in the compile time. By default, assets cache is build on the fly:

```
assetsExtension:
	cacheBuilder: \CacheBuilder
```

Use prepared interface:

```
class CacheBuilder implements \h4kuna\Assets\DI\ICacheBuilder
{
	public function create(\h4kuna\Assets\CacheAssets $cache, $wwwDir)
	{
		$finder = Nette\Utils\Finder::findFiles('*')->in($wwwDir . '/config');
		foreach ($finder as $file) {
			/* @var $file \SplFileInfo */
			$cache->load(self::replaceSlashOnWindows($file));
		}
	}

	private static function replaceSlashOnWindows(SplFileInfo $file)
	{
		static $isWindows;
		if ($isWindows === NULL) {
			$isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
		}

		if ($isWindows) {
			return str_replace('\\', '/', $file->getPathname());
		}
		return $file->getPathname();
	}
}
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 73.3% 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 ~224 days

Recently: every ~391 days

Total

8

Last Release

1749d ago

Major Versions

0.1.5 → v1.0.02020-03-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/54b4efb9b89167fa3598b1a41477b20387390f4a0fb65b447bd6bb7c30a49020?d=identicon)[h4kuna](/maintainers/h4kuna)

---

Top Contributors

[![h4kuna](https://avatars.githubusercontent.com/u/335722?v=4)](https://github.com/h4kuna "h4kuna (11 commits)")[![slischka](https://avatars.githubusercontent.com/u/19595920?v=4)](https://github.com/slischka "slischka (2 commits)")[![adaamz](https://avatars.githubusercontent.com/u/4347332?v=4)](https://github.com/adaamz "adaamz (1 commits)")[![paveljanda](https://avatars.githubusercontent.com/u/1488874?v=4)](https://github.com/paveljanda "paveljanda (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/h4kuna-assets/health.svg)

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

###  Alternatives

[nette/code-checker

✅ Nette CodeChecker: A simple tool to check source code against a set of Nette coding standards.

881.7M6](/packages/nette-code-checker)[uestla/twigrid

Experimental DataGrid for Nette Framework

1712.3k2](/packages/uestla-twigrid)

PHPackages © 2026

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