PHPackages                             codebjorn/mjolnir - 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. codebjorn/mjolnir

ActiveLibrary[Framework](/categories/framework)

codebjorn/mjolnir
=================

WordPress Utility Framework

0.1.1(4y ago)39192MITPHPPHP &gt;=7.1

Since May 29Pushed 4y ago3 watchersCompare

[ Source](https://github.com/codebjorn/mjolnir)[ Packagist](https://packagist.org/packages/codebjorn/mjolnir)[ Docs](https://github.com/quotesun/mjolnir)[ RSS](/packages/codebjorn-mjolnir/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (2)

 [![](https://camo.githubusercontent.com/916eee7acdc9abec73f2a0d5c096880fb17666191f9c6dff274fb008ba8b03f1/68747470733a2f2f692e696d6775722e636f6d2f7042654533724f2e706e67)](https://camo.githubusercontent.com/916eee7acdc9abec73f2a0d5c096880fb17666191f9c6dff274fb008ba8b03f1/68747470733a2f2f692e696d6775722e636f6d2f7042654533724f2e706e67)

Mjölnir, WordPress Utility Framework
====================================

[](#mjölnir-wordpress-utility-framework)

[![GitHub release](https://camo.githubusercontent.com/eee02c4e8947558bdb4a1fa4fedede912c90e4e9e6fda967e108c07559b254ca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f636f6465626a6f726e2f6d6a6f6c6e69723f696e636c7564655f70726572656c6561736573)](https://github.com/codebjorn/mjolnir/releases)[![Generic badge](https://camo.githubusercontent.com/52ad996b081d948d6585b4cb6efabd2c9d3daf5d07fadc7c3738021f01879222/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53746162696c6974792d416c7068612d6f72616e67652e737667)](https://shields.io/)

Mjölnir is small utility framework that gives utilities and possibilities to create WordPress plugins &amp; themes using best of PHP. This package is compliant with PSR-1, PSR-2, PSR-4 and PSR-11.

If you think this approach is not working, please open an issue and let's discuss :)

Already made implementations
----------------------------

[](#already-made-implementations)

To see already made implementations please check official boilerplates:

- [Loki](https://github.com/codebjorn/loki) - WordPress Theme Boilerplate
- [Thor](https://github.com/codebjorn/thor) - WordPress Plugin Boilerplate

Pre-Requirements
----------------

[](#pre-requirements)

Before we proceed further:

1. I suggest you to read documentation of [PHP League Container](https://container.thephpleague.com/3.x/).
    Mjölnir it uses as to provide Dependency Injection in your application.
2. Also, if you will use default template engine, check documentation of [BladeOne](https://github.com/EFTEC/BladeOne)

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

[](#requirements)

Requirements for this framework are:

- PHP 7.1+
- Composer

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

[](#installation)

You can install framework via composer:

```
composer require codebjorn/mjolnir
```

Copy stubs from folder `stubs` to your folder, rename `app` folder if is need it and update `{{namespace}}` with application namespace

In a nutshell
-------------

[](#in-a-nutshell)

Base of framework is dependency injection container, that stores some utility classes for: configuration, render, exception handling, hooks, blocks and all other services that you add and resolve, after all of that you add your service to hook.

As example, you have class that add some WP functionality `PostTypes.php`, you resolve all dependencies in `ServiceProvider` and after apply it to a hook

Utilities
---------

[](#utilities)

To explain how utilities works, let's take a look to each namespace that has utilities

#### Admin

[](#admin)

Admin namespace contains utilities for add new features on admin side:

1. `Option.php` is a wrapper of functions related to Option Api, examples:

```
\Mjolnir\Admin\Option::get('someOption');
\Mjolnir\Admin\Option::update('someOption', 'someContent');
```

2. `Page.php` is a wrapper for all functions related to creating a page in admin, examples:

```
\Mjolnir\Admin\Page::dashboard('Page', 'Page', 'read', 'page');
\Mjolnir\Admin\Page::management('Page', 'Page', 'read', 'page');
```

#### Content

[](#content)

Content namespace contains utilities for creating different content solutions that WordPress has:

1. `PostType.php` allows you easy to create different custom post types, example:

```
$books = \Mjolnir\Content\PostType::make('Books')
    ->supports(['title', 'editor'])
    ->public(true)
    ->showInRest(true);

$books->register(); //Call register to exit creating of arguments
```

2. `Taxonomy.php` allows you easy to create different taxonomies, example:

```
$countries = \Mjolnir\Content\Taxonomy::make('Countries')
    ->postTypes(['books'])
    ->public(true)
    ->showInRest(true);

$countries->register(); //Call register to exit creating of arguments
```

3. `Shortcode.php` is a wrapper for functions related to Shortcode Api, example:

```
\Mjolnir\Content\Shortcode::add('hello', [$this, 'hello']);
\Mjolnir\Content\Shortcode::do('[hello]');
```

#### Database

[](#database)

Database namespace contains utilities for database interaction:

1. `Query.php` is a wrapper for WP Query arguments

```
$metaQuery = new \Mjolnir\Database\Parameter\Meta([
    new \Mjolnir\Database\Parameter\MetaArgument('key', 'value', 'NUMERIC', '='),
    new \Mjolnir\Database\Parameter\MetaArgument('key', 'value', 'DATE', '>'),
]);
$tax = new \Mjolnir\Database\Parameter\Tax(null, [
    new \Mjolnir\Database\Parameter\TaxArgument('taxonomy', 'field', 'term1'),
    new \Mjolnir\Database\Parameter\TaxArgument('taxonomy', 'field', 'term2'),
]);

$posts = new \Mjolnir\Database\Query();
$posts->postType('posts')
    ->meta($metaQuery)
    ->tax($tax)
    ->pagination(5);

$posts->make(); // return new WP_Query
$posts->get(); // returns Collection
$posts->getRaw(); //return Array
```

#### Routing

[](#routing)

Routing namespace contains utilities related to routing system of WordPress such as Api:

1. `Api.php` is a wrapper of all functions related to REST API, example:

```
\Mjolnir\Routing\Api::make('/namespace', '/users')
    ->get([$this, 'getUsers'], '_return_true')
    ->post([$this, 'postUsers'], [$this, 'isAdmin']);
```

#### Support

[](#support)

Support namespace contains utilities that will help you work with data:

1. `Arr.php` is utility class that allows you to manipulate with array, examples:

```
$first = \Mjolnir\Support\Arr::first($array);
$key = \Mjolnir\Support\Arr::get($array, 'key');
```

2. `Collection.php` is class for working with arrays of data, examples:

```
$collection = \Mjolnir\Support\Collection::make($array);
$filtered = $collection->where('key', 'value');
$reversed = $filtered->reverse();
```

2. `Is.php` is wrapper for functions to determine type of variable, examples:

```
\Mjolnir\Support\Is::file($value);
\Mjolnir\Support\Is::str($value);
\Mjolnir\Support\Is::int($value);
```

3. `Str.php` is class to manipulate with string, examples:

```
$string = \Mjolnir\Support\Str::make('some string');
$reversed = $string->flip();
$contains = $string->has('some');
```

#### Utils

[](#utils)

Utils namespace contains utilities for working with plugins and themes:

1. `Enqueue.php` is wrapper of functions related to enqueue, example:

```
\Mjolnir\Utils\Enqueue::style('theme-style', 'folder/style.css', [], '1.0.0', 'all');
\Mjolnir\Utils\Enqueue::script('theme-script', 'folder/script.css', [], '1.0.0', true);
\Mjolnir\Utils\Enqueue::all();
```

2. `Post.php` is wrapper of WP\_Post that gives better API to get post, example:

```
$currentPost = \Mjolnir\Utils\Post::current();
$post = \Mjolnir\Utils\Post::get(1);
$postId = $post->getId();
$postSlug = $post->getSlug();
```

3. `Theme.php` is wrapper of functions related to theme, example:

```
\Mjolnir\Utils\Theme::support('feature');
\Mjolnir\Utils\Theme::textDomain('domain', 'path');
\Mjolnir\Utils\Theme::mod()->set('item', 'value');
\Mjolnir\Utils\Theme::mod()->get('item');
```

Facades
-------

[](#facades)

Facades are API that allows you to create a class that will get resolved class from container, check `stubs/app/Facades`to check default facades:

1. `Action.php` give access to action hook, example:

```
{{Namespace}}\Facades\Action::do('hook');
{{Namespace}}\Facades\Action::add('hook', [$this, 'function']);
{{Namespace}}\Facades\Action::group('hook')
    ->add([$this, 'function'])
    ->add(SomeClass::class)
    ->add(function () {
        echo "something todo";
    });
```

2. `Filter.php` give access to filter hook, example:

```
{{Namespace}}\Facades\Filter::apply('filter');
{{Namespace}}\Facades\Filter::add('filter', [$this, 'function']);
{{Namespace}}\Facades\Filter::group('filter')
    ->add([$this, 'function'])
    ->add(SomeClass::class)
    ->add(function () {
        echo "something todo";
    });
```

3. `Block.php` give access to class related to block, example:

```
{{Namespace}}\Facades\Block::add('namespace', 'name');
{{Namespace}}\Facades\Block::exists('namespace/name');
{{Namespace}}\Facades\Block::group('namespace')
    ->add('name')
    ->add('name');
```

4. `Config.php` give access to config files, example:

```
{{Namespace}}\Facades\Config::get('configFile.index.anotherIndex');
{{Namespace}}\Facades\Config::get('app.view.folder');
```

5. `View.php` give access to view file for render, example:

```
{{Namespace}}\Facades\View::render('books.single');
{{Namespace}}\Facades\View::render('books/single.blade.php');
```

### Testing

[](#testing)

//TODO

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Dorin Lazar](https://github.com/codebjorn)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Total

2

Last Release

1813d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/52886764?v=4)[Dorin Lazar](/maintainers/codebjorn)[@codebjorn](https://github.com/codebjorn)

---

Top Contributors

[![codebjorn](https://avatars.githubusercontent.com/u/52886764?v=4)](https://github.com/codebjorn "codebjorn (61 commits)")

---

Tags

quotesunmjolnir

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codebjorn-mjolnir/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[cakephp/core

CakePHP Framework Core classes

6026.8M39](/packages/cakephp-core)[wpbones/wpbones

WordPress framework for Laravel developers

1714.8k1](/packages/wpbones-wpbones)

PHPackages © 2026

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