PHPackages                             jacknoordhuis/threaded-class-loader - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. jacknoordhuis/threaded-class-loader

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

jacknoordhuis/threaded-class-loader
===================================

A thread safe implementation of a PSR-0, PSR-4 and classmap class loader for use with the pthreads extension.

0.0.2(7y ago)016LGPL-3.0PHPPHP &gt;=7.1

Since Feb 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/JackNoordhuis/threaded-class-loader)[ Packagist](https://packagist.org/packages/jacknoordhuis/threaded-class-loader)[ RSS](/packages/jacknoordhuis-threaded-class-loader/feed)WikiDiscussions master Synced 2d ago

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

PHP Threaded Class Loader Package
=================================

[](#php-threaded-class-loader-package)

*A thread safe implementation of a PSR-0, PSR-4 and classmap class loader for use with the pthreads extension!*

[![Build Status](https://camo.githubusercontent.com/cb0b9fedb3ad7da88a82aa33bd240ebd82dc121fdd9d23284f3d9eca10e3bcbb/68747470733a2f2f7472617669732d63692e6f72672f4a61636b4e6f6f7264687569732f74687265616465642d636c6173732d6c6f616465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/JackNoordhuis/threaded-class-loader)

The core advantage of having a central thread safe class loader is that new classes can be registered to the loader, on any thread, and when PHP tries to load the class from any thread the loader is also registered on, everything will 'just work' as they shared \\Threaded objects.

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

[](#installation)

### Composer

[](#composer)

Via command line:

```
$ composer require jacknoordhuis/threaded-class-loader
```

Or add the package to your `composer.json`:

```
{
    "require": {
        "jacknoordhuis/threaded-class-loader": "*"
    }
}
```

Usage
-----

[](#usage)

Here is a basic example of replacing the default composer class loader:

```
$loader = require_once "vendor/autoload.php";
$loader = jacknoordhuis\Autoload\ThreadedClassLoader::fromComposerLoader($loader);
```

This example will load the composer autoloader so that our threaded loader can be loaded, then we call the helper method which conveniently handles converting composers mappings to \\Threaded members. Depending on the extra arguments provided the helper method will also (by default) unregister the composer loader and register the new thread safe loader on the current thread.

You can now safely pass the `$loader` to a new thread and call the `ThreadedClassLoader::register()` method to load the classes on the new thread.

```
$loader = ...; //put example code from above here

class MyWorker extends \Worker {

	public $loader;

	public function __construct($loader) {
		$this->loader = $loader;
	}

	public function run() {
		$this->loader->register();

		//put your code here
	}
}

$worker = new MyWorker($loader);
$worker->start() && $worker->join();
```

\_\_The content of this repo is licensed under the GNU Lesser General Public License v3. A full copy of the license is available \[here\](LICENSE).\_\_

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Every ~1 days

Total

2

Last Release

2695d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10399774?v=4)[Jack Noordhuis](/maintainers/JackNoordhuis)[@JackNoordhuis](https://github.com/JackNoordhuis)

---

Top Contributors

[![JackNoordhuis](https://avatars.githubusercontent.com/u/10399774?v=4)](https://github.com/JackNoordhuis "JackNoordhuis (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jacknoordhuis-threaded-class-loader/health.svg)

```
[![Health](https://phpackages.com/badges/jacknoordhuis-threaded-class-loader/health.svg)](https://phpackages.com/packages/jacknoordhuis-threaded-class-loader)
```

###  Alternatives

[aura/di

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

352982.2k60](/packages/aura-di)[maclof/kubernetes-client

A simple yet elegant client for accessing and controlling a Kubernetes cluster.

234907.8k4](/packages/maclof-kubernetes-client)[icamys/php-sitemap-generator

Simple PHP sitemap generator.

175356.9k7](/packages/icamys-php-sitemap-generator)

PHPackages © 2026

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