PHPackages                             gcworld/objectmanager - 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. gcworld/objectmanager

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

gcworld/objectmanager
=====================

GCWorld Industries Object Manager

2.8.6(1y ago)030.7k1MITPHPPHP &gt;=8.4

Since May 18Pushed 1w ago1 watchersCompare

[ Source](https://github.com/KongHack/Object-Manager)[ Packagist](https://packagist.org/packages/gcworld/objectmanager)[ RSS](/packages/gcworld-objectmanager/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (4)Versions (45)Used By (1)

GCWorld Object Manager
======================

[](#gcworld-object-manager)

A simple object manager that maintains objects in memory

#### Version

[](#version)

2.9.2

### ObjectManager Attributes

[](#objectmanager-attributes)

Use PHP attributes instead of docblocks to mark classes for manager generation.

#### Class Attribute

[](#class-attribute)

```
use GCWorld\ObjectManager\Attributes\ObjectManagerAttribute;
use GCWorld\ObjectManager\Enums\ObjectManagerMethod;

#[ObjectManagerAttribute(method: ObjectManagerMethod::GetObject, gc: 100)]
class User
{
}
```

Available `ObjectManagerAttribute` arguments:

ArgumentRequiredNotes`method`yes`ObjectManagerMethod::GetObject`, `::GetModel`, `::GetFactoryObject`, `::GetFactoryModelObject``name`noGetter suffix override. Defaults to the class short name.`namespace`noNamespace override used in generated manager methods.`gc`noAutomated garbage-collection limit. `0` disables it.These enum cases map to the generated manager behaviors `getObject`, `getModel`, `getFactoryObject`, and `getFactoryModelObject`.

#### Factory Methods

[](#factory-methods)

Factory-backed classes use a class attribute plus one or more attributed public static methods.

```
use GCWorld\ObjectManager\Attributes\ObjectFactoryAttribute;
use GCWorld\ObjectManager\Attributes\ObjectManagerAttribute;
use GCWorld\ObjectManager\Enums\ObjectManagerMethod;

#[ObjectManagerAttribute(method: ObjectManagerMethod::GetFactoryObject)]
class User
{
    public const CLASS_PRIMARY = 'uuid';

    #[ObjectFactoryAttribute]
    public static function factoryByUuid(string $uuid): self
    {
        // ...
    }

    #[ObjectFactoryAttribute]
    public static function factoryLookup(string $email, string $name): self
    {
        // ...
    }
}
```

The generator reflects the attributed static method parameters directly. There is no separate attribute syntax for ordered factory args.

### Generating The Manager

[](#generating-the-manager)

Generate the manager after your models are autoloadable and your scan path has been added:

```
use GCWorld\ObjectManager\Generator;

$generator = new Generator();
$generator->addPath(__DIR__.'/src/Model');
$generator->generate();
```

This writes the generated manager class to `src/Generated/GeneratedManager.php`.

### Testing

[](#testing)

The repository includes a PHPUnit suite that exercises the generator against fixture models.

```
composer test
```

Current coverage is focused on:

- basic attributed object getter generation
- factory wrapper generation from attributed static methods
- `getFactoryModelObject` wrapper generation
- invalid `#[ObjectFactoryAttribute]` usage on non-public or non-static methods

The tests generate a temporary manager file under `src/Generated/` during execution and clean it up afterward.

### Migrating Legacy `@om-*` Docblocks

[](#migrating-legacy-om--docblocks)

Legacy class docblocks can be converted to attributes with the bundled migration script.

Dry run:

```
composer migrate-docblocks -- --dry-run path/to/src
```

Apply changes:

```
composer migrate-docblocks -- path/to/src
```

What the migrator does:

- converts class-level `@om-method`, `@om-name`, `@om-namespace`, and `@om-gc` tags into `#[ObjectManagerAttribute(...)]` using `ObjectManagerMethod`
- converts each `@om-factory-X-method` entry into `#[ObjectFactoryAttribute]` on the matching class method
- removes legacy `@om-*` lines from the class docblock while preserving unrelated docblock text
- adds the required `use GCWorld\ObjectManager\Attributes\ObjectManagerAttribute;`, `use GCWorld\ObjectManager\Attributes\ObjectFactoryAttribute;`, and `use GCWorld\ObjectManager\Enums\ObjectManagerMethod;` imports

The script only migrates factory metadata when every referenced legacy factory method can be resolved in the class. If a declared factory method is missing, the file is skipped and a warning is reported so existing metadata is not destroyed.

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance75

Regular maintenance activity

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity93

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 96.5% 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 ~85 days

Recently: every ~147 days

Total

44

Last Release

406d ago

Major Versions

1.1.3 → 2.0.02015-10-06

PHP version history (5 changes)1.0.0PHP &gt;=5.4.0

2.1.0PHP &gt;=5.6.0

2.3.0PHP &gt;=7.1

2.6.0PHP &gt;=7.2.5

2.8.5PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1208565?v=4)[Gamecharmer](/maintainers/GameCharmer)[@GameCharmer](https://github.com/GameCharmer)

---

Top Contributors

[![GameCharmer](https://avatars.githubusercontent.com/u/1208565?v=4)](https://github.com/GameCharmer "GameCharmer (111 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")

### Embed Badge

![Health badge](/badges/gcworld-objectmanager/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

318117.1k1](/packages/cognesy-instructor-php)[october/rain

October Rain Library

1581.7M73](/packages/october-rain)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M528](/packages/shopware-core)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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