PHPackages                             gamernetwork/yolk-core - 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. [Framework](/categories/framework)
4. /
5. gamernetwork/yolk-core

AbandonedArchivedLibrary[Framework](/categories/framework)

gamernetwork/yolk-core
======================

Gamer Network's PHP framework core

v1.0(10y ago)07.0k11MITPHPPHP &gt;=5.4.0

Since Jul 24Pushed 10y ago9 watchersCompare

[ Source](https://github.com/gamernetwork/yolk-core)[ Packagist](https://packagist.org/packages/gamernetwork/yolk-core)[ RSS](/packages/gamernetwork-yolk-core/feed)WikiDiscussions develop Synced 1mo ago

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

Want to work for Gamer Network? [We are hiring!](http://www.gamesindustry.biz/jobs/gamer-network)

Yolk Core
=========

[](#yolk-core)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fd0ec29aa0f9ab8c9650a59b4a081e8c59b94dae447fc149921238c3f871b9b4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67616d65726e6574776f726b2f796f6c6b2d636f72652f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/gamernetwork/yolk-core/?branch=develop)

The lightweight core of Gamer Network's PHP framework. Provides error and exception handling and commonly used helper functions.

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

[](#requirements)

This library requires only PHP 5.4 or later and the Yolk Contracts package (`gamernetwork/yolk-contracts`).

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

[](#installation)

It is installable and autoloadable via Composer as `gamernetwork/yolk-core`.

Alternatively, download a release or clone this repository, and add the `\yolk` namespace to an autoloader.

License
-------

[](#license)

Yolk Core is open-sourced software licensed under the MIT license.

Quick Start
-----------

[](#quick-start)

Yolk Core provides a basic exception and error handling wrapper for blocks of code, be they command-line scripts, complete web apps or simple functions.

Running code with Yolk is a simple as calling the static `run()` method with a `callable` parameter.

```
use yolk\Yolk;

// Using a closure
Yolk::run(function() {
  echo "Hello World";
});

// Using a function name
function hello() {
  echo "Hello World";
}
Yolk::run('hello');

// Using an object...
class Foo {
  public static function hello() {
    echo "Hello World";
  }
  public function helloWorld() {
    echo "Hello World";
  }
  public function __invoke() {
    $this->helloWorld();
  }
}

// ...static callback
Yolk::run(['Foo', 'hello']);

// ...instance callback
$o = new Foo();
Yolk::run([$o, 'hello']);

// ...invokable object
Yolk::run($o);
```

Error and Exception Handling
----------------------------

[](#error-and-exception-handling)

Yolk Core provides default error and exception handlers:

- Errors are converted to ErrorExceptions() and passed to the exception handler.
- Exceptions result in an error page being displayed (for web scripts) or the exception being dumped to stdout (for CLI scripts)

You can override the default handlers by passing a callable to the appropriate method:

```
use yolk\Yolk;

Yolk::setErrorHandler($callback);

Yolk::setExceptionHandler($callback);
```

Debug Flag
----------

[](#debug-flag)

Yolk provides a debug flag accessible via:

```
use yolk\Yolk;

// enabled/disable debug flag
Yolk::setDebug(true);

// Return current setting of debug flag
Yolk::isDebug();
```

Usage of the debug flag is left almost entirely to clients. The only uses within the framework are:

- to determine whether to display a detailed error page (if debug flag is set) or a simple static error page
- calls to the `d()` and `dd()` dump functions are ignored if the debug flag is not set

The default simple static error page can be overriden: by passing the path and file name to the ```

```
use yolk\Yolk;

Yolk::setErrorPage($path_to_file);
```

Variable Dumping
----------------

[](#variable-dumping)

Yolk provides an enhanced `var_dump()` implementation that can output detailed variable information in plain text, html or terminal (CLI) formats.

```
use yolk\Yolk;

/**
 * $var - any variable or constant
 * $format - one of null, Yolk::DUMP_TEXT, Yolk::DUMP_HTML, Yolk::DUMP_TERMINAL
 */
Yolk::dump($var, $format = null);
```

If no format or null is specified then Yolk will auto-detect the appropriate output - `DUMP_TERMINAL` will be used within CLI environments and `DUMP_HTML` will be used for web environments.

Yolk will also define two shortcut functions for accessing the variable dumping functionality:

- `d()` - calls `Yolk::dump()` for each passed argument
- `dd()` - same as `d()` but will call `die()` once the arguments have been dumped

These shortcut methods do nothing is the debug flag is not set.

Helpers
-------

[](#helpers)

Yolk provides a variety of helper functions and more can be easily added. Helper functions are implemented as static class methods and registered either by passing the class name to the `Yolk::registerHelper()` method (registers all public static methods) or by passing a class and method name to the `Yolk::addHelperMethod()` (registers a single method). Once registered helper functions can be called via static method call to `Yolk`.

```
use yolk\Yolk;

class MyHelper {
  public static function foo() {
    echo 'foo';
  }
  public static function bar() {
    echo 'bar';
  }
}

Yolk::registerHelper('\\MyHelper');

Yolk::foo();
Yolk::bar();
```

### General Helpers

[](#general-helpers)

- `isCLI()` - determines if the script is running in a CLI environment

### Array Helpers

[](#array-helpers)

- `uniqueIntegers()` - return an array of unique integers
- `isTraversable()` - determines if a variable can be interated over using `foreach`
- `isAssoc()` - determine if an array is associative or not
- `filterObjects()` - filter an array to instances of a specific class
- `get()` - return an item from an array or object or a default value if the item doesn't exist
- `getNullItems()` - filter an array to items that are null
- `pluck()` - extract a single field from an array of arrays of objects
- `sum()` - calculate the sum of the specified item from an array of arrays or objects
- `min()` - calculate the min of the specified item from an array of arrays or objects
- `max()` - calculate the max of the specified item from an array of arrays or objects
- `implodeAssoc()` - implode an associative array into an array of key/value pairs
- `makeComparer()` - create a comparison function for sorting multi-dimensional arrays

### Date/Time Helpers

[](#datetime-helpers)

- `makeTimestamp` - convert a value into a timestamp
- `seconds()` - convert a string representation containing one or more of hours, minutes and seconds into a total number of seconds

### String Helpers

[](#string-helpers)

- `parseURL()` - parse a url into an array of it's components
- `randomHex()` - generate a random hex string of a specific length
- `randomString()` - generate a random string of a specific length
- `uncamelise()` - convert a camel-cased string to lower case with underscores
- `slugify()` - convert a string into a form suitable for urls
- `removeAccents()` - convert accented characters to their regular counterparts
- `latin1()` - convert a UTF-8 string into Latin1 (ISO-8859-1)
- `utf8()` - convert a Latin1 (ISO-8859-1) into UTF-8
- `ordinal()` - return the ordinal suffix (st, nd, rd, th) of a number
- `sizeFormat()` - convert a number of bytes to a human-friendly string using the largest suitable unit
- `xssClean()` - remove XSS vulnerabilities from a string
- `stripControlChars()` - remove control characters from a string

### Inflection Helpers

[](#inflection-helpers)

- `pluralise()` - Determine the plural form of a word (English only)
- `singularise()` - Determine the single form of a word (English only)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

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

Unknown

Total

1

Last Release

3952d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2658e540902cbc1f59ec171e1b74515fb9e7c3a1e194e37e9c37f27ae400e4b4?d=identicon)[gamer-network](/maintainers/gamer-network)

---

Top Contributors

[![simon-downes](https://avatars.githubusercontent.com/u/1052903?v=4)](https://github.com/simon-downes "simon-downes (4 commits)")

---

Tags

frameworkeurogamergamer network

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gamernetwork-yolk-core/health.svg)

```
[![Health](https://phpackages.com/badges/gamernetwork-yolk-core/health.svg)](https://phpackages.com/packages/gamernetwork-yolk-core)
```

###  Alternatives

[hemp/presenter

Easy Model Presenters in Laravel

247592.6k1](/packages/hemp-presenter)[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)[wpstarter/framework

The WpStarter Framework - Laravel Framework for WordPress

1810.1k4](/packages/wpstarter-framework)

PHPackages © 2026

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