gcworld / orm
GCWorld Industries ORM
Requires
- php: >=8.4
- ext-json: *
- ext-pdo: *
- composer/composer: ^2.10
- composer/installers: ^2.3
- gcworld/common: ^2.7
- gcworld/database: ^2.7
- gcworld/globals: ^4.0
- gcworld/interfaces: ^4.4
- monolog/monolog: ^3.10
- nette/php-generator: ^4.2
- ramsey/uuid: ^4.9
- symfony/yaml: ^6.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- 6.5.0
- 6.4.34
- 6.4.33
- 6.4.32
- 6.4.31
- 6.4.30
- 6.4.29
- 6.4.28
- 6.4.27
- 6.4.26
- 6.4.25
- 6.4.24
- 6.4.23
- 6.4.22
- 6.4.21
- 6.4.20
- 6.4.19
- 6.4.18
- 6.4.17
- 6.4.16
- 6.4.15
- 6.4.14
- 6.4.13
- 6.4.12
- 6.4.11
- 6.4.10
- 6.4.9
- 6.4.8
- 6.4.7
- 6.4.6
- 6.4.5
- 6.4.4
- 6.4.3
- 6.4.2
- 6.4.1
- 6.4.0
- 6.3.7
- 6.3.6
- 6.3.5
- 6.3.4
- 6.3.3
- 6.3.2
- 6.3.1
- 6.3.0
- 6.2.6
- 6.2.5
- 6.2.4
- 6.2.3
- 6.2.2
- 6.2.1
- 6.2.0
- 6.1.5
- 6.1.4
- 6.1.3
- 6.1.2
- 6.1.1
- 6.1.0
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.7.3
- 5.7.2
- 5.7.1
- 5.7.0
- 5.6.5
- 5.6.4
- 5.6.3
- 5.6.2
- 5.6.1
- 5.6.0
- 5.5.5
- 5.5.4
- 5.5.3
- 5.5.2
- 5.5.1
- 5.4.7
- 5.4.6
- 5.4.5
- 5.4.4
- 5.4.3
- 5.4.2
- 5.4.1
- 5.4.0
- 5.3.5
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4.0.2
- 2.4.0.1
- 2.4.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0.1
- 2.1.0
- 2.0.0.0
- 1.4.2
- 1.4.1.2
- 1.4.1.1
- 1.4.1
- 1.4.0.2
- 1.4.0.1
- 1.4.0
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.0
- dev-jules_wip_14507409134709776028
- dev-php84-optimizations
This package is auto-updated.
Last update: 2026-09-17 18:30:57 UTC
README
GCWorld ORM generates database-backed PHP model classes from a live schema. Generated models provide field metadata, getters and setters, persistence, factory methods for unique keys, optional Redis caching, validation helpers, and configurable change auditing.
The package supplies generation and runtime infrastructure. The consuming application remains responsible for database connections, its Common and user implementations, schema migrations, configuration, and when generation runs.
Version
6.5.0
Requirements
- PHP 8.4 or newer
- Composer 2
- The JSON and PDO PHP extensions
- A
GCWorld\Interfaces\CommonInterfaceimplementation that provides the configured database and optional cache connections - A database whose schema can be inspected during model generation
Installation
Install the package with Composer:
composer require gcworld/orm
The Composer installer creates config/GCWorld_ORM.yml in the consuming
project when that file does not already exist. Start with the generated example
and replace its Common and user class names before loading or generating models.
Configuration
The main configuration controls global generation behavior and per-table or per-field overrides:
version: 5 general: common: '\App\Common' user: '\App\CurrentUser' audit: true trust_cache: false database_name: default sub_namespace: '' options: get_set_funcs: true var_visibility: protected json_serialize: true use_defaults: true defaults_override_null: true type_hinting: true cache_after_purge: false tables: Member: constructor: public cache_ttl: 60 fields: member_uuid: uuid_field: true visibility: protected type_hint: string required: true
Table definitions may also be split into individual YAML files by setting
table_dir to a directory relative to the main config. See
the complete configuration reference for all global, table,
field, description, auditing, and caching options.
Generating models
Construct Core with the consuming application's Common implementation, then
generate each table that should have a model:
use GCWorld\ORM\Core; $orm = new Core(__NAMESPACE__, $common); $query = $common->getDatabase()->query('SHOW TABLES'); while ($table = $query->fetchColumn()) { $orm->generate($table); }
Generated abstract classes are written beneath src/Generated/ in this package
and use the GCWorld\ORM\Generated namespace. If general.sub_namespace is
set, it is added beneath both the directory and namespace. The generated tree
is ignored by Git and should be rebuilt from the schema and configuration
during the application's setup or deployment process.
The database user used for generation must be able to inspect columns and indexes. Generation does not replace schema migrations and should run only against a schema controlled by the application.
Using generated models
Application models extend their generated base and expose the methods enabled
by the configuration. For a Member table, a minimal model can be loaded and
changed as follows:
use GCWorld\ORM\Generated\Member as GeneratedMember; final class Member extends GeneratedMember { } $member = new Member(42); $member->setEmail('person@example.com'); $member->save();
Exact class and factory names follow table, primary-key, and unique-index names
from the schema. Generated classes also expose change tracking through
_hasChanged(), _getChanged(), and _getLastChanged().
DirectDBClass is available when an application needs public generic get(),
set(), getArray(), and setArray() access in addition to generated field
methods.
Caching and auditing
Caching is enabled per table through cache_ttl and uses the cache returned by
the configured Common implementation. A value of -1 disables caching, 0
keeps entries without an ORM expiration, and a positive value sets the lifetime
in seconds. cache_after_purge controls whether a saved object is immediately
cached again.
Auditing can be disabled globally, per table, or per field. The default audit
handler records before-and-after values using the application's audit database
configuration. Applications may provide a custom class implementing
AuditInterface; sensitive fields should use audit_ignore when their values
must not be retained in change logs.
Local development
The supported local environment uses the public KongHack PHP 8.4 image:
./dc up -d ./dc exec php composer install ./dc exec php composer check ./dc down
The committed Compose configuration mounts only this repository. It does not
expose host SSH keys or Composer credentials. Developers who require private
Composer authentication can copy docker-compose.override.yml.example to the
ignored docker-compose.override.yml; that override exposes credentials to
container processes and should only be enabled when needed.
Individual quality commands are also available:
./dc exec php composer lint ./dc exec php composer phpstan ./dc exec php composer phpcs ./dc exec php composer test
PHPStan is enforced at level 6. PHPCS enforces PSR-12 errors while retaining the three underscore-prefixed change-tracking methods as a legacy public API. GitHub Actions runs the complete suite on PHP 8.4 and 8.5.
Releases
Releases use bare semantic-version tags such as 6.4.34. Before tagging a
release:
- Add release notes under the matching version heading in
CHANGELOG.md. - Update
VERSIONand the value immediately below### Versionin this file. - Push the release commit and matching tag.
GitHub Actions validates the release metadata and complete PHP quality matrix
before creating a GitHub Release from CHANGELOG.md. Release tags must not be
moved or reused.
License
GCWorld ORM is open-source software licensed under the MIT License.