PHPackages                             wheregroup/joii - 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. wheregroup/joii

AbandonedComponent[Utility &amp; Helpers](/categories/utility)

wheregroup/joii
===============

Javascript Object Inheritance Implementation

3.2.0(9y ago)05.2kMITJavaScript

Since Apr 20Pushed 9y ago2 watchersCompare

[ Source](https://github.com/WhereGroup/joii)[ Packagist](https://packagist.org/packages/wheregroup/joii)[ Docs](http://joii.harold.info)[ RSS](/packages/wheregroup-joii/feed)WikiDiscussions release/3.2 Synced 2w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

[![GitHub version](https://camo.githubusercontent.com/d88da63ce8c961ca360a5dd1a8efaf412d5ddd66c99c366fb48aece446243df3/68747470733a2f2f62616467652e667572792e696f2f67682f6861726f6c64696564656d612532466a6f69692e737667)](https://badge.fury.io/gh/haroldiedema%2Fjoii) [![Build Status](https://camo.githubusercontent.com/a297834754294c6bcbc426352eb1e53955690c3838c687bfc8c30ee398f4f8ae/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6861726f6c64696564656d612f6a6f69692f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/haroldiedema/joii/build-status/master) [![npm version](https://camo.githubusercontent.com/4e573a1d043bc243debf160aecef2e926600e5c60bbde810fb8dbdfc19cc5596/68747470733a2f2f62616467652e667572792e696f2f6a732f6a6f69692e737667)](https://badge.fury.io/js/joii)

What is JOII?
=============

[](#what-is-joii)

JOII (short for JavaScript Object Inheritance Implementation) brings ***class- based programming to JavaScript*** without the use of a compiler. Everything is done using native JavaScript. JOII allows you to build your applications using Classes and Interfaces as you would in most other object oriented languages. JOII is built with the priciple of being compatible with *any*browser on the market. Therefore, JOII is supported by Internet Explorer 5.5 and anything that came after that.

[Full documentation can be found here](https://joii.harold.info/)

Features
--------

[](#features)

- Support Internet Explorer 5.5 and up
- [Build](https://joii.harold.info/class/introduction) and [extend](https://joii.harold.info/class/inheritance) on classes
- Support for [interfaces](https://joii.harold.info/interface/introduction)
- Strong [typehinting](https://joii.harold.info/meta/types) in class properties
- [Typehinting](https://joii.harold.info/meta/types) for custom object definitions
- [Visibility setting](https://joii.harold.info/meta/visibility) (public, protected)
- [Final](https://joii.harold.info/meta/final) &amp; [abstract](https://joii.harold.info/meta/abstract) properties and methods
- [Traits / Mix-ins](https://joii.harold.info/class/traits)
- [Enums](https://joii.harold.info/enum/introduction)
- [Reflection](https://joii.harold.info/reflection/introduction)
- (since 3.1.0) Custom constructor and callable method names

License
-------

[](#license)

Like most other popular JavaScript libraries, JOII is released under the [MIT license](https://en.wikipedia.org/wiki/MIT_License).

The MIT License is simple and easy to understand and it places almost no restrictions on what you can do with a JOII project. You are free to use any JOII-project in any other project (even commercial projects) as long as the copyright header is left intact. All sample codes on this website are public domain, meaning you're free to do with them as you please.

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

[](#installation)

### Browser

[](#browser)

Load JOII like any other library. JOII does not require any dependencies.

```

```

> JOII is available as a bower package: `bower install joii`

### Node

[](#node)

Install using npm and automatically add to your package.json file using `--save` if you want.

```
npm install joii --save
```

Somewhere, in your node project:

```
// JOII registers itself in the global namespace once loaded.
require("joii");

var MyClass = Class({ /* ... /* });
```

### Running unit tests

[](#running-unit-tests)

1. Clone the repository from here.
2. Install dependencies through npm via `npm install`
3. Run the testsuite using the command `npm test`
4. Optionally, open `testsuite.html` in a browser to see the browser-version of the unit tests.

Sneak peek
----------

[](#sneak-peek)

This is an example of what JOII looks like in action.

```
// Define a simple class called "Person".
var Person = Class({

    // Declare a property called 'name'.
    'public immutable string name' : null,

    // Declare a constructor to be executed upon instantiation.
    'private construct': function (name) {
        this.name = name;
    }
});

// Define a class called "Employee" that extends on "Person"
var Employee = Class({ extends: Person }, {

    // Add an 'occupation' property.
    'public nullable string occupation' : null,

    // Override the constructor from "Person".
    'private construct' : function (name, occupation) {
        // invoke the parent constructor
        this.super('construct', name);

        // Set the given occupation.
        this.setOccupation(occupation);
    }
});

var bob = new Employee('Bob');
bob.setOccupation('Developer');

console.log(bob.getName()); // Bob
console.log(bob.getOccupation()); // Developer
```

As you can see, the example code uses setter and getter methods that we didn't define. When a property is declared *public*, JOII automatically generates getters and setters for this property and enforces type checking in them.

> Properties are not exposed to the public, even if they are declared to be.

```
// properties are never exposed to the public, this is undefined:
bob.occupation;

// This will throw an exception, because occupation must be a string:
bob.setOccupation(123);
```

When a property is declared protected, getters and setters are still generated but are not exposed to the public. When a property is declared private, nothing is generated.

Find out more about this in the [getters and setters](https://joii.harold.info/class/getters-and-setters)section.

Custom constructor methods
--------------------------

[](#custom-constructor-methods)

As of 3.1.0, it's possible to add custom constructor methods. To ensure full compatibility with other JOII-based libraries, constructor method names are only added and never replaced. When a constructor method is found, no more of these will be executed upon instantiation.

You can add custom constructor method names using `JOII.Config.addConstructor('hello');`

For example:

```
// Add the 'hello' constructor.
JOII.Config.addConstructor('hello');

var Hi = Class({
    hello: function () {
        console.log('Hello World!');
    }
});

// Outputs: "Hello World!"
new Hi();
```

Beware that original / existing constructors are leading, meaning they'll be executed first.

```
var Hi = Class({
    hello: function () {
        // I am never executed.
        console.log('Hello World!');
    }

    // __construct is the 'original' constructor, so it gets more priority over the
    // newly added one, 'hello'.
    __construct: function () {
        console.log('Hi there.');
    }
});
```

[Full documentation can be found here](https://joii.harold.info/)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 90.2% 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

3358d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/0154eb5bdfa738d2bbc95bb345ba5f971d9395a2318f8724e42fa3bd384ae9c2?d=identicon)[LazerTiberius](/maintainers/LazerTiberius)

---

Top Contributors

[![haroldiedema](https://avatars.githubusercontent.com/u/567518?v=4)](https://github.com/haroldiedema "haroldiedema (110 commits)")[![georgePadolsey](https://avatars.githubusercontent.com/u/2631084?v=4)](https://github.com/georgePadolsey "georgePadolsey (4 commits)")[![cjmanca](https://avatars.githubusercontent.com/u/6020593?v=4)](https://github.com/cjmanca "cjmanca (3 commits)")[![mpccolorado](https://avatars.githubusercontent.com/u/560804?v=4)](https://github.com/mpccolorado "mpccolorado (3 commits)")[![eSlider](https://avatars.githubusercontent.com/u/1188335?v=4)](https://github.com/eSlider "eSlider (1 commits)")[![x3rAx](https://avatars.githubusercontent.com/u/2268851?v=4)](https://github.com/x3rAx "x3rAx (1 commits)")

---

Tags

enumjavascriptinterfaceclassenumeratorextendsprivatepublicOOPinheritancevisibilityprotectedjoii

### Embed Badge

![Health badge](/badges/wheregroup-joii/health.svg)

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

###  Alternatives

[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89454.3M347](/packages/nette-robot-loader)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49753.5M104](/packages/marc-mabe-php-enum)[ducks-project/spl-types

Polyfill Module for SplType PHP extension. This extension aims at helping people making PHP a stronger typed language and can be a good alternative to scalar type hinting. It provides different typehandling classes as such as integer, float, bool, enum and string

1032.9k](/packages/ducks-project-spl-types)

PHPackages © 2026

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