PHPackages                             vaersaagod/toolmate - 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. vaersaagod/toolmate

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

vaersaagod/toolmate
===================

Is that a tool in your pocket, or are you just happy to see me, mate?

1.5.0(2y ago)31.8k1[1 issues](https://github.com/vaersaagod/toolmate/issues)MITPHPPHP ^8.0CI failing

Since May 10Pushed 2y ago3 watchersCompare

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

READMEChangelog (9)Dependencies (3)Versions (19)Used By (0)

ToolMate plugin for Craft CMS
=============================

[](#toolmate-plugin-for-craft-cms)

Is that a tool in your pocket, or are you just happy to see me, mate!

[![Screenshot](resources/plugin_logo.png)](resources/plugin_logo.png)

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 3.1.0 or later.

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

[](#installation)

To install the plugin, either install it from the plugin store, or follow these instructions:

1. Install with composer via `composer require vaersaagod/toolmate` from your project directory.
2. Install the plugin in the Craft Control Panel under Settings → Plugins, or from the command line via `./craft install/plugin toolmate`.

---

Configuring
-----------

[](#configuring)

ToolMate can be configured by creating a file named `toolmate.php` in your Craft config folder, and overriding settings as needed.

### publicRoot \[string\]

[](#publicroot-string)

*Default: `@webroot`*

Sets the public webroot that is used by inline and stamp on servers where `$_SERVER['DOCUMENT_ROOT']` and `@webroot` is incorrect.

### enableMinify \[bool\]

[](#enableminify-bool)

*Default: `true`*

Enables/disables all minifying.

### embedCacheDuration \[int|string|bool|null\]

[](#embedcacheduration-intstringboolnull)

*Default: `null`*

The number of seconds to cache responses from `craft.toolmate.getVideoEmbed()`.

If set to `null`, the core [`cacheDuration`](https://craftcms.com/docs/3.x/config/config-settings.html#cacheduration) setting is used.

If set to `false` responses are not cached.

If set to `0`, cached responses will be stored indefinitely.

See [`craft\helpers\ConfigHelper::durationInSeconds()`](https://docs.craftcms.com/api/v3/craft-helpers-confighelper.html#method-durationinseconds) for a list of supported value types.

### embedCacheDurationOnError \[int|string|bool|null\]

[](#embedcachedurationonerror-intstringboolnull)

*Default: `300` (5 minutes)*

The number of seconds to cache responses from `craft.toolmate.getVideoEmbed()` when there is an error (i.e. a valid embed code could not be returned).

If set to `null`, the default value (`300`, 5 minutes) is used.

If set to `false`, error responses are not cached.

If set to `0`, error response caches will be stored indefinitely.

See [`craft\helpers\ConfigHelper::durationInSeconds()`](https://docs.craftcms.com/api/v3/craft-helpers-confighelper.html#method-durationinseconds) for a list of supported value types.

### csp \[array|null\]

[](#csp-arraynull)

*Default `null`*

Configure the Content-Security-Policy header set by Toolmate. Some useful tips:

- Avoid using `unsafe-inline` and `unsafe-eval` policies, especially for the `script-src` directive. CSP nonces should ideally be used for inline script or style tags, see the `cspNonce()` Twig function.
- Nonces and `unsafe-inline` cannot be combined. Toolmate works around this to avoid CSP errors, but TLDR; is that you don't need to set nonces if you're also using `unsafe-inline`.
- CSP nonces generated by `cspNonce()` are safe to put inside `{% cache %}` tags
- To enable data-URLs, add a `data:` policy to the relevant directives
- For CP requests, Toolmate will always add the necessary `unsafe-inline` and `unsafe-eval` policies, because the CP isn't possible to use without.

#### csp\[enabled\] \[bool\]

[](#cspenabled-bool)

*Default `false`*

If set to `false`, the CSP header will not be sent for any requests.

#### csp\[enabledForCp\] \[bool\]

[](#cspenabledforcp-bool)

*Default `false`*

If set to `false`, the CSP header will only be sent for site requests.

#### csp\[reportOnly\] \[bool\]

[](#cspreportonly-bool)

*Default `false`*

If set to `true`, the CSP header will be sent, but not enforced (i.e. dry-run mode). Useful for testing policies.

#### csp\[directives\] \[array\]

[](#cspdirectives-array)

See , and the example config below.

### Example CSP configuration:

[](#example-csp-configuration)

```
'csp' => [
    'enabled' => true,
    'enabledForCp' => false,
    'reportOnly' => false,
    'directives' => [
        'defaultSrc' => [
            "'self'",
        ],
        'scriptSrc' => [
            "'self'",
            "'unsafe-inline'",
        ],
        // Sources for stylesheets
        'styleSrc' => [
            "'self'",
            "'unsafe-inline'",
        ],
        // Sources for images
        'imgSrc' => [
            "'self'",
            'https://some-project.imgix.net',
            'data:'
        ],
        // Sources for iframes
        'frameSrc' => [
            "'self'",
            'https://www.youtube.com https://player.vimeo.com https://www.facebook.com https://www.googletagmanager.com https://bid.g.doubleclick.net',
        ],
        // Domains that are allowed to iframe this site
        'frameAncestors' => [
            "'self'",
        ],
        'baseUri' => [
            "'none'",
        ],
        'connectSrc' => [],
        'fontSrc' => [
            //"'self'",
        ],
        'objectSrc' => [],
        'mediaSrc' => [],
        'sandbox' => [],
        'reportUri' => [],
        'childSrc' => [],
        'formAction' => [],
        'reportTo' => [],
        'workerSrc' => [],
        'manifestSrc' => [],
        'navigateTo' => [],
    ],
],
```

---

Template variables
------------------

[](#template-variables)

### craft.toolmate.inline(filename \[, remote=false\])

[](#crafttoolmateinlinefilename--remotefalse)

```
{{ craft.toolmate.inline('/assets/critical.css') }}

```

### craft.toolmate.stamp(filename \[, mode = 'file', type = 'ts'\])

[](#crafttoolmatestampfilename--mode--file-type--ts)

```
{# /assets/bundle.1522425799.js #}
{{ craft.tool.stamp('/assets/bundle.js') }}

{# /assets/1522425799/bundle.js #}
{{ craft.tool.stamp('/assets/bundle.js', 'folder') }}

{# /assets/5140247221/bundle.js #}
{{ craft.tool.stamp('/assets/bundle.js', 'folder', 'hash') }}

{# /assets/bundle.js?ts=1522425799 #}
{{ craft.tool.stamp('/assets/bundle.js', 'query') }}

{# 1522425799 #}
{{ craft.tool.stamp('/assets/bundle.js', 'tsonly') }}

```

### craft.toolmate.setCookie(params \[, secure = false\])

[](#crafttoolmatesetcookieparams--secure--false)

```
{% do craft.toolmate.setCookie({ name: 'testing', value: 'Just testing!' }) %}
{% do craft.toolmate.setCookie({ name: 'testingsecure', value: { lorem: 'ipsum', dolor: 'sit amet' } }, true) %}

{% set params = {
    name: 'cookiename',
    value: 'thevalue',
    expire: 0,
    path: '/',
    domain: '',
    secure: false,
    httpOnly: false,
    sameSite: null,
} %}

{% do craft.toolmate.setCookie(params) %}

```

### craft.toolmate.getCookie(name \[, secure = false\])

[](#crafttoolmategetcookiename--secure--false)

```
{{ craft.toolmate.getCookie('testing') }}
{{ dump(craft.toolmate.getCookie('testingsecure', true)) }}

```

### craft.toolmate.getVideoEmbed(url \[, params = \[\]\])

[](#crafttoolmategetvideoembedurl--params--)

```
{% set videoEmbed = craft.toolmate.getVideoEmbed(videoUrl, {
    youtube_enablejsapi: 1,
    youtube_rel: 0,
    youtube_showinfo: 0,
    youtube_controls: 1,
    youtube_autoplay: 0,
    youtube_modestbranding: 1,
    youtube_playsinline: 0,
    vimeo_byline: 0,
    vimeo_title: 0,
    vimeo_autoplay: 0,
    vimeo_portrait: 0
}) %}

```

---

Twig tags
---------

[](#twig-tags)

### minify

[](#minify)

```

    {% minify css %}
        .lorem {
            width: 200px;
        }
        .ipsum {
            padding: 0px;
        }
    {% endminify %}

    {% minify js %}
        var myFunction = function () {
            console.log('Some inline JS');
        }
    {% endminify %}

{% minify html %}

        Some html

{% endminify %}

```

---

Twig functions
--------------

[](#twig-functions)

### inline(filename \[, remote=false\])

[](#inlinefilename--remotefalse)

See `craft.toolmate.inline`.

### stamp(filename \[, mode = 'file', type = 'ts'\])

[](#stampfilename--mode--file-type--ts)

See `craft.toolmate.stamp`.

### setCookie(params \[, secure = false\])

[](#setcookieparams--secure--false)

See `craft.toolmate.setCookie`.

### getCookie(name \[, secure = false\])

[](#getcookiename--secure--false)

See `craft.toolmate.getCookie`.

### getVideoEmbed(url \[, params = \[\]\])

[](#getvideoembedurl--params--)

See `craft.toolmate.getCookie`.

### cspNonce(directive, \[, asAttribute = false, hash = true\])

[](#cspnoncedirective--asattribute--false-hash--true)

Output a CSP nonce. Example:

```

   console.log('Hello world');

```

```

    body { ... }

```

```
{% js 'foo.js' with { nonce: cspNonce('script-src') } %}
```

---

Price, license and support
--------------------------

[](#price-license-and-support)

The plugin is released under the MIT license. It's made for Værsågod and friends, and no support is given. Submitted issues are resolved if it scratches an itch.

Changelog
---------

[](#changelog)

See [CHANGELOG.MD](https://raw.githubusercontent.com/vaersaagod/toolmate/master/CHANGELOG.md).

Credits
-------

[](#credits)

Brought to you by [Værsågod](https://www.vaersaagod.no)

Icon designed by [Freepik from Flaticon](https://www.flaticon.com/authors/freepik).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~92 days

Recently: every ~162 days

Total

16

Last Release

814d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2580dc72f65006fb038f68d3299615d97cdda269d0d487639a89cf2628b1176f?d=identicon)[vaersaagod](/maintainers/vaersaagod)

---

Top Contributors

[![aelvan](https://avatars.githubusercontent.com/u/2675644?v=4)](https://github.com/aelvan "aelvan (16 commits)")[![mmikkel](https://avatars.githubusercontent.com/u/298510?v=4)](https://github.com/mmikkel "mmikkel (15 commits)")[![alexbech](https://avatars.githubusercontent.com/u/803499?v=4)](https://github.com/alexbech "alexbech (1 commits)")

---

Tags

craft-plugincraft3craftcmsminifyworkflowcmscookiesCraftcraftcmscraft-plugininlinetimestampmate

### Embed Badge

![Health badge](/badges/vaersaagod-toolmate/health.svg)

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

###  Alternatives

[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[verbb/tablemaker

Create customizable and user-defined table fields.

40168.8k1](/packages/verbb-tablemaker)[supercool/tablemaker

Create customizable and user-defined table fields.

40141.7k](/packages/supercool-tablemaker)[verbb/vizy

A flexible visual editor field for Craft.

4348.6k](/packages/verbb-vizy)

PHPackages © 2026

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