PHPackages                             underdev/utils - 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. underdev/utils

ActiveLibrary

underdev/utils
==============

WordPress utilities

1.1.3(7y ago)1787↓100%1PHPPHP &gt;=5.3.9

Since Jul 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Kubitomakita/Utils)[ Packagist](https://packagist.org/packages/underdev/utils)[ RSS](/packages/underdev-utils/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (8)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/3cec590b05c3886934343c3cd21de0dec662108de6e414c2dfacf5515494d6db/68747470733a2f2f706f7365722e707567782e6f72672f756e6465726465762f7574696c732f762f737461626c65)](https://packagist.org/packages/underdev/utils) [![Total Downloads](https://camo.githubusercontent.com/c1b79ea2ea58537cf1a1e383045fd0331f2af4a57927767d3c021089c59aeba6/68747470733a2f2f706f7365722e707567782e6f72672f756e6465726465762f7574696c732f646f776e6c6f616473)](https://packagist.org/packages/underdev/utils) [![Latest Unstable Version](https://camo.githubusercontent.com/bdcae1b27b65f5d07f0d9948cc61de4838b223ef29bac5b62cd1fd80546814ed/68747470733a2f2f706f7365722e707567782e6f72672f756e6465726465762f7574696c732f762f756e737461626c65)](https://packagist.org/packages/underdev/utils)

WordPress utilities classes for plugin development

Usage example
=============

[](#usage-example)

Include the Composer's autoloader first.

```
require_once( 'vendor/autoload.php' );
```

Singleton
---------

[](#singleton)

```
use underDEV\Utils\Singleton;

class Example extends Singleton {}

Example::get();
```

AJAX
----

[](#ajax)

Helper for AJAX requests.

```
use underDEV\Utils\Ajax;

function ajax_callback() {

	$ajax = new Ajax();

	// verify nonce
	// you can pass the $_REQUEST array key for nonce as the second argument
	$ajax->verify_nonce( 'key_for_nonce' );

	// do stuff
	// ...

	// send output
	// if errors array will not be empty, it's considered as an error respose
	$ajax->response( $success = 'success message', $errors = array() );

}
```

Files
-----

[](#files)

Helper for plugin's files.

```
use underDEV\Utils\Files;

// argument should be the main plugin file
$files = new Files( __FILE__ );

// get asset url
// will return: your-plugin/assets/dist/css/style.css
$files->asset_url( 'css', 'style.css' )

// get vendor asset url
// will return: your-plugin/assets/vendor/vendor_name/asset.css
$files->vendor_asset_url( 'vendor_name', 'asset.css' )
```

For all methods please check the class source.

View
----

[](#view)

Helper for loading views. Uses the Files class.

```
use underDEV\Utils\Files;
use underDEV\Utils\View;

// argument should be the main plugin file
$files = new Files( __FILE__ );
$view  = new View( $files );

// set some view var
$view->set_var( 'var_name', 'value' );

// load view
// this will load ./views/parts/menu.php
$view->get_view( 'parts/menu' );
```

In template file you can get vars

```
get_var( 'var_name' ); ?>
```

To have different scopes in templates you have to instantinate different classes.

Cache
-----

[](#cache)

Interface for cache. Has two implementations:

- Object Cache - if WordPress cache is not set it will not persist
- Transient Cache

### Basic usage

[](#basic-usage)

```
use underDEV\Utils\Cache\ObjectCache;
use underDEV\Utils\Cache\Transient;

// create new cache object giving it a key and group
$cached_object = new ObjectCache( 'object_key', 'object_group' );
var_dump( $cached_object->get() ); // inspect cached value

// create new transient cache giving it a key and expiration in seconds
$transient_cache = new Transient( 'transient_key', 3600 );
var_dump( $transient_cache->get() ); // inspect cached value
```

### Injecting cached element into a class

[](#injecting-cached-element-into-a-class)

```
use underDEV\Utils\Interfaces\Cacheable;
use underDEV\Utils\Cache\ObjectCache;
use underDEV\Utils\Cache\Transient;

class MyClass {

	/**
	 * Cached object
	 * @var mixed
	 */
	protected $cached_element;

	/**
	 * Constructor
	 * @param Cacheable $cached_element
	 */
	public function __construct( Cacheable $cached_element ) {
		$this->cached_element = $cached_element;
	}

	public function inspect_element() {
		var_dump( $this->cached_element->get() );
	}

}

$myclass = new MyClass( new ObjectCache( 'object_key', 'object_group' ) );
$myclass->inspect_element(); // dumps object cached variable

// you can substitute MyClass constructor argument with
// any object of class that implements Cacheable
$myclass = new MyClass( new Transient( 'transient_key', 3600 ) );
$myclass->inspect_element(); // dumps cached transient variable
```

See Cacheable interface for all available methods.

Dice
----

[](#dice)

Dependency injection container. Forked from Tom Butler's Dice lib. Compatible with PHP 5.4

[Dice usage](https://r.je/dice.html)

###  Health Score

31

—

LowBetter than 71% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

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

Recently: every ~116 days

Total

6

Last Release

2706d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

wordpresswordpress-plugins

### Embed Badge

![Health badge](/badges/underdev-utils/health.svg)

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

PHPackages © 2026

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