Download the PHP package gcworld/objectmanager without Composer
On this page you can find all versions of the php package gcworld/objectmanager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gcworld/objectmanager
More information about gcworld/objectmanager
Files in gcworld/objectmanager
Package objectmanager
Short Description GCWorld Industries Object Manager
License MIT
Informations about the package objectmanager
GCWorld Object Manager
A simple object manager that maintains objects in memory
Version
2.9.3
ObjectManager Attributes
Use PHP attributes instead of docblocks to mark classes for manager generation.
Class Attribute
Available ObjectManagerAttribute arguments:
| Argument | Required | Notes |
|---|---|---|
method |
yes | ObjectManagerMethod::GetObject, ::GetModel, ::GetFactoryObject, ::GetFactoryModelObject |
name |
no | Getter suffix override. Defaults to the class short name. |
namespace |
no | Namespace override used in generated manager methods. |
gc |
no | Automated garbage-collection limit. 0 disables it. |
These enum cases map to the generated manager behaviors getObject, getModel, getFactoryObject, and getFactoryModelObject.
Classes in different namespaces may share a short name. The generator keeps those classes distinct by their fully qualified class names, but generated PHP methods must still have unique names. Use the attribute's name argument to disambiguate the getter while preserving the existing getter for the other class:
This example generates getADRMember(). Generation fails with a descriptive exception if two classes would produce the same getter name.
Factory Methods
Factory-backed classes use a class attribute plus one or more attributed public static methods.
The generator reflects the attributed static method parameters directly. There is no separate attribute syntax for ordered factory args.
Generating The Manager
Generate the manager after your models are autoloadable and your scan path has been added:
This writes the generated manager class to src/Generated/GeneratedManager.php.
Testing
The repository includes a PHPUnit suite that exercises the generator against fixture models.
Current coverage is focused on:
- basic attributed object getter generation
- factory wrapper generation from attributed static methods
getFactoryModelObjectwrapper 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
Legacy class docblocks can be converted to attributes with the bundled migration script.
Dry run:
Apply changes:
What the migrator does:
- converts class-level
@om-method,@om-name,@om-namespace, and@om-gctags into#[ObjectManagerAttribute(...)]usingObjectManagerMethod - converts each
@om-factory-X-methodentry 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;, anduse 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.
All versions of objectmanager with dependencies
composer/composer Version >=2.7
gcworld/utilities Version >=2.0
symfony/yaml Version ^6.0