Componette

Componette

nextras

nextras / orm v5.0.0

Orm with clean object design, smart relationship loading and powerful collections.

download-cloud-line composer require nextras/orm

Nextras Orm

Build Status Downloads this Month Stable Version Code coverage

Lightweight and high-performance ORM with clean object design.

Supported platforms:

  • MySQL,
  • PostgreSQL,
  • MS SQL Server.

Docs & resources

Extensions

License

MIT. See full license.

  • v5.0.0 5.0.0

    Major changes:

    • ๐Ÿ˜ The minimum PHP version is 8.1 [31043a3]
    • โ›บ Introduction of PHPDoc generics, fully supporting PHPStan, and making the code safer [404b47b, ab9cdcf, 3dcb20b, e8a90db]
    • ๐Ÿ“‹ Added support for PHP 8's Enums [#585]
    • ๐Ÿ“ฆ Added row aggregations for relationships and great refactoring of Collection functions [#496, #531, #545, #546, #542, #566, #587, #633, #652, #655, #685, #687, #698]
    • ๐Ÿ›ก๏ธ Introduced literal-string PHPDoc type to prevent SQL injection [d88eb6e]

    Minor changes:

    • Allow working with a has-one relationship before attachment to the repository [#467]
    • HasMany::set() optimized to avoid unneeded remove/add [#512]
    • Introduced MemoryCollection and related ICollection::toMemoryCollection() [#533]
    • Support for instances of OrmExtension [#660]
    • relationship: reading removed entity re-tracks it by [#510]
    • Entity::hasValue() should not set null value for the uninitialized property by [#514]
    • Added ICollection::fetchChecked() [#554]
    • Support nullable classes definition with '?' [#556]
    • conventions: fix ManyHasMany keys lookup on MySql with different key casing [#581]
    • Use spl_object_id instead of spl_object_hash [#605]
    • [Nette] Initialize metadata on DIC startup [#606]
    • mixed type allows null [#595]
    • Relationships fixes in HasOne [#620]
    • Use PhpDocParser for property parsing [#680]
    • Add a workaround for same-named columns in GROUP BY for MySQL [#664]

    Thank you!
    Special thanks to @stepapo for thorough testing and bug reporting.
    Thanks to new contributors @ondrejmirtes, @ste93cry, @radimvaculik, @qwerin, @Anry7794, @Zazimou, @jkavalik.

    Full Changelog: v4.0.7...v5.0.0

  • v5.0.0-rc3 v5.0.0-rc3

    What's Changed since rc2

    We found that SQL "rewrites" for Any aggregation produces non-optimal SQL code compared to Orm 4.0 - SQL queries were using HAVING clause when they didn't have to. CollectionFunctions' processing was rewritten to two-phase processing allowing us better detection when the HAVING clause is needed. This is a major change since the last RC.

    • Two-phase SQL rewrites by @hrach in #687
    • Fix having lifting required by row aggregator by @hrach in #698
    • Add support for stable phpdoc-parser 1.x branch [caca579]
    • Fix detection of boolean type property (it worked in Orm 4.0) [7765573]

    Special thanks to @stepapo for thorough testing and bug reporting.

    Full Changelog: v5.0.0-rc2...v5.0.0-rc3

  • v5.0.0-rc2 v5.0.0-rc2

    What's Changed

    • Add workaround for same-named columns in GROUP BY for MySQL by @hrach in #664
    • Fix missing aggregation key on m:m joining table by @hrach in #665
    • Fix Date(time) instance in primary key by @jkavalik in #677
    • Use PhpDocParser for property parsing by @hrach in #680
    • separate WHERE & HAVING in expression result & fix buggy having rewrite by @hrach in #685

    New Contributors

    Full Changelog: v5.0.0-rc1...v5.0.0-rc2

  • v5.0.0-rc1 v5.0.0-rc1

    Major changes:

    • ๐Ÿ˜ The minimum PHP version is 8.1 [31043a3]
    • โ›บ Introduction of PHPDoc generics, fully supporting PHPStan, and making the code safer [404b47b, ab9cdcf, 3dcb20b, e8a90db]
    • ๐Ÿ“‹ Added support for PHP 8's Enums [#585]
    • ๐Ÿ“ฆ Added row aggregations for relationships and great refactoring of Collection functions [#496, #531, #545, #546, #542, #566, #587, #633, #652, #655]
    • ๐Ÿ›ก๏ธ Introduced literal-string PHPDoc type to prevent SQL injection [d88eb6e]

    Minor changes:

    • Allow working with a has-one relationship before attachment to the repository [#467]
    • HasMany::set() optimized to avoid unneeded remove/add [#512]
    • Introduced MemoryCollection and related ICollection::toMemoryCollection() [#533]
    • Support for instances of OrmExtension [#660]
    • relationship: reading removed entity retracks it by [#510]
    • Entity::hasValue() should not set null value for uninitialized property by [#514]
    • Added ICollection::fetchChecked() [#554]
    • Support nullable classes definition with '?' [#556]
    • conventions: fix ManyHasMany keys lookup on MySql with different key casing [#581]
    • Use spl_object_id instead of spl_object_hash [#605]
    • [Nette] Initialize metadata on DIC startup [#606]
    • mixed type allows null [#595]
    • Relationships fixes in HasOne [#620]

    New Contributors:

    Thank you!

    Full Changelog: v4.0.7...v5.0.0-rc1

  • v4.0.7 4.0.7

    What's Changed

    • [Nette] Initialize metadata on DIC startup - v4.0 by @mabar in #590
    • allow nette/utils 4.0 by @hrach in #632

    Full Changelog: v4.0.6...v4.0.7

  • v4.0.6 4.0.6

    • fix nullable type ?Type parsing [#592]
  • v4.0.5 4.0.5

    What's Changed

    • Add missing array key checks when using the debug_backtrace() function, #552 by @ste93cry
    • Conventions: fix ManyHasMany keys lookup on MySql with different key casing, #578

    Full Changelog: v4.0.4...v4.0.5

  • v4.0.4 4.0.4

    New patch version 4.0.4 is out! โ„๏ธ What's changed from 4.0.3?

    • fixed support for PHP 8.1 [2c40588]
    • build v4 branch with GitHub actions

    See full commit changelog.

  • v4.0.3 4.0.3

    New patch version 4.0.3 is out! โ˜€ What's changed from 4.0.2?

    • relationship: reading removed entity retracks it [4bea473]
    • repository: revert obtaining entity by entity instance (temporarily to easy update to v4) [d3586f8]

    See full commit changelog.

    You may support Nextras Orm by giving it a star here on GitHub โญ or by Sponsorship (even with a one-time payment).
    Thanks to current sponsors: @stpnkcrk, @vaclavpavek, @chemix, @radimvaculik, @zraly, @manweCZ, @stepapo ๐Ÿค—

  • v4.0.2 4.0.2

    New patch version 4.0.2 is out! ๐ŸŒฑ What's changed from 4.0.1?

    • dbal conventions: removed buggy optimization for finding M:M mapping columns [6763e43]
    • array mapper: fix resolving relationship mapper for proper data storage in ArrayMapper [4218ff6]

    Thanks @martenb for report.

    See full commit changelog.

    You may support Nextras Orm by giving it a star here on GitHub โญ or by Sponsorship.
    Thanks to current sponsors: @stpnkcrk, @davidkregl, @vaclavpavek, @chemix, @radimvaculik, @zraly, @manweCZ. ๐Ÿค—

  • v4.0.1 4.0.1

    New patch version 4.0.1 is out! ๐ŸŽƒ What's changed from 4.0.0?

    • collection: fix HasManyCollection::fetch() accessing invalid iterator state, thanks VojtaBrtnik for reporting [734cd96]

    See full commit changelog.

    You may support Nextras Orm by giving it a star here on GitHub โญ or by Sponsorship.
    Thanks to current sponsors: @stpnkcrk, @vaclavpavek, @chemix and @radimvaculik. ๐Ÿค—

  • v4.0.0 4.0.0

    The major 4.0.0 version is out! ๐ŸŒบ

    What's new: โœ”

    BC breaks: โ—

    See full commit changelog since 3.1 version. ๐Ÿ“ƒ

    You may support Nextras Orm by giving it a star here on GitHub โญ or by Sponsorship.
    Thanks to current sponsors: @stpnkcrk, @vaclavpavek and @chemix. ๐Ÿค—

  • v3.1.4 3.1.4

    New patch version 3.1.4 is out! ๐Ÿด What's changed from 3.1.3?

    • relationships: fix counting 1:M table with composite primary key, thanks @LuckyLuky for reporting [d781eb3]

    See full commit changelog.

    You may support Nextras Orm by giving it a star here on GitHub โญ or by Sponsorship.
    Thanks to current sponsors: @stpnkcrk, @vaclavpavek and @chemix. ๐Ÿค—

  • v4.0.0-rc1 4.0.0 RC1

    The release candidate of major 4.0.0 version is out!

    What's new: โœ”

    BC breaks: โ—

    See full commit changelog since 3.1 version. ๐Ÿ“ƒ

    The work and this release is sponzored - thanks to all donors. ๐Ÿ’ฐ

  • v3.1.3 3.1.3

    New patch version 3.1.3 is out! ๐Ÿˆ What's changed from 3.1.2?

    • fixed updating reverse side of relationship [d495ee1]

    See full commit changelog.

    You may support Nextras Orm by giving it a star here on GitHub โญ or by Sponsorship.

  • v3.1.2 3.1.2

    New patch version 3.1.2 is out! ๐Ÿฃ What's changed from 3.1.1?

    • fixed possibly uninitialized storage reflection in DbalMapper #403 [dd9d092]

    Thanks bug reporters: @honzarac.

    See full commit changelog.

  • v3.1.1 3.1.1

    New patch version 3.1.1 is out! ๐ŸŒต What's changed from 3.1.0?

    • fixed joining the same table multiple times over different relationships #390 [a52a013]
    • fixed invalidate state after persist & before flush #386 [8f98094][3ff59e1]
    • fixed counting a relationship filtered by multilpe has-many conditions #393 [8ac61d4]

    Thanks bug reporters: @step0s, @jtojnar.

    See full commit changelog.

  • v3.1.0 3.1.0

    New minor version 3.1.0 is out. ๐Ÿ˜

    What's new:

    • dropped support for PHP 7.0 [a9cccdd]
    • added support for collection filtering of IPropertyContainters - full support for enum converters [4d1a2dc]
    • added better support for composite primary keys [a0883a2], #290
    • added simple traversing support in fetchPairs() [0a6f7ca], #312
    • added "Did you mean...?" suggestion in exception message [15ef449]
    • added support for Nette 3 components

    BC breaks:
    Please check your code for the following patters to fix the compatibility:

    • (BC break!) Collection filtering by id property accepts only direct values, no Entity itself [4d1a2dc]
    • (BC break!) changed IProperty interface and introduced IEntityAwareProperty [0c46be1]
    • (BC break!) IRepository::remove() accepts only already fetched entities, [a6458da]
    • (BC break!) DbalMapper::getManyHasManyParameters() was receiving the second parameter randomly, sometime it were the metadata of symetric relationship [5521b89]

    See full commit changelog.


    You may support Nextras Dbal & Orm development by attending Akademie42 training.

  • v3.1.0-rc1 3.1 RC1

    Release candidate 1 of new minor 3.1.0 version is out.

    Notable news:

    • dropped support for PHP 7.0 [a9cccdd]
    • fixed support for collection filtering of IPropertyContainters - now it's possible to fully support enums [4d1a2dc]
    • better support for composite primary keys [a0883a2], #290
    • added simple traversing support in fetchPairs() [0a6f7ca], #312
    • implemented "Did you mean...?" [15ef449]
    • added support for Nette 3 components
    • (BC break!) Collection filtering by id property accepts only direct values, no Entity itself [4d1a2dc]
    • (BC break!) changed IProperty interface and introduced IEntityAwareProperty [0c46be1]
    • (BC break!) IRepository::remove() accepts only already fetched entities, [a6458da]
    • (BC break!) DbalMapper::getManyHasManyParameters() was receiving the second parameter randomly, sometime it were the metadata of symetric relationship [5521b89]

    See full commit changelog.

    You may support Nextras Dbal & Orm development by attending Akademie42 training.

  • v3.0.3 3.0.3

    Stable patch version 3.0.3 is out! ๐Ÿ What's changed from 3.0.2?

    • fixed DILoader for anonymous classes & compatibility with latest Nette DI 2.5.14, thanks @pavelmlejnek (#333)

    See full commit changelog.

  • v3.0.2 3.0.2

    Stable patch version 3.0.2 is out! ๐ŸŒ What's changed from 3.0.1?

    • fixed casting numeric column names, thanks @vymak (#287)
    • fixed saving DateTimeImmutable for DATE type, not shifting timezone anymore, thanks @sitole
    • fixed phpdoc of doRefreshAll()
    • removed not-needed auto-distinct

    See full commit changelog.

  • v3.0.1 3.0.1

    Stable patch version 3.0.1 is out! ๐Ÿˆ What's changed from 3.0.0?

    • readded support for Nextras\Dbal\Utils\DateTimeImmutable property type
    • fixed EntityCreator support for DateTimeImmutable
    • fixed return value of Repository::removeAndFlush()
    • fixed dependency on Nextras Dbal to stable release

    See full commit changelog.

  • v3.0.0 3.0.0

    This is new major 3.0.0 version. ๐ŸŽ‰ ๐Ÿฐ ๐Ÿฅ‡ ๐Ÿ’ฏ

    Read a release blogpost.

    What's new:

    • PHP 7.0+ code; added types, support for PHP 7.2;
    • model: added IModel::clear() method;
    • model: added IModel::refreshAll() method;
    • collection: added OR operator support;
    • collection: added custom functions allowing advanced modification of ICollection;
    • entity: added DateTimeImmutable support;
    • entity: fixed a lot of issues between relationships, their caching, and persistence;
    • added MS SQL support;
    • dropped support for DateTime (BC break!);

    We have introduced many small and some larger BC breaks, read Upgrade notes for 3.0.

    See full commit changelog.

  • v3.0.0-rc2 3.0.0 RC2

    This is prerelease RC 2 of major 3.0.0 version.

    What's changed from RC1:

    • fixed auto-setup of DbalMapperCoordinator when Dbal extension is registered later than Orm extension

    See full commit changelog.

  • v3.0.0-rc1 3.0.0 RC1

    This is prerelease RC 1 of major 3.0.0 version.

    What's new from 2.2 branch:

    • PHP 7.0+ code; added types, fixed support for PHP 7.2;
    • model: added IModel::clear() method;
    • model: added IModel::refreshAll() method;
    • collection: added OR operator support;
    • collection: added custom functions allowing advanced modification of ICollection;
    • entity: added DateTimeImmutable support;
    • dropped support for DateTime (BC break!);
    • entity: fixed a lot of issues between relationships, their caching, and persistence;
    • added MS SQL support;

    We have introduced many small and some larger BC breaks, read Upgrade notes for 3.0.

    See full commit changelog.

  • v3.0.0-beta2 3.0.0 BETA 2

    See 3.0 changes in BETA 1 release notes.

    Changes since BETA 1:

    • require IConnection instead Connection
    • fixed multi-column primary key comparison in changed entity detection in has one relationship
    • fixed many typos and smalling with PhpStan 0.9
    • fixed distinct count for MS SQL Server
    • added ICollection::getById()
    • fixed loading DI services in loadConfiguraiton of Nette DIC
    • fixed countStored() on many has many relationship
    • fixed disctinct selection for multi-column PR tables
    • fixed parsing of read-only properties
    • changed implementation of DI repository finder
    • fixed STI in multientity interator
    • See full commit changelog since 3.0-BETA1 version.
  • v3.0.0-beta1 3.0.0 BETA 1

    This is prerelease BETA 1 of major 3.0.0 version.

    What's new from 2.2 branch:

    • PHP 7.0+ code; added typehints, fixed support for PHP 7.2;
    • model: added IModel::clear() method;
    • model: added IModel::refreshAll() method;
    • collection: added OR support & custom functions;
    • entity: added DateTimeImmutable support, dropped support for DateTime
    • entity: fixed a lot of issues between relationships, their caching, and perstitence.
    • engines: added MS SQL support;

    We have introduced many small and some larger BC breaks, read Upgrade notes for 3.0.

    See full commit changelog.

    How to install:

    • set require for 3.0 version od Nextras Dbal nextras/dbal@rc
    • set require for 3.0 version od Nextras Orm nextras/orm@beta
  • v2.2.3 2.2.3

    Stable patch version 2.2.3 is out! ๐Ÿฅ› What's changed from 2.2.2?

    • fixed bug when metadata parser didn't parsed enum with wildcard without a name prefix, e.g. ClassWithConstants::* now works correctly. [6e46e40]
  • v2.2.2 2.2.2

    Stable patch version 2.2.2 is out! ๐Ÿˆ What's changed from 2.2.1?

    • fixed bug when total cache cleanup didn't flush relationship mapper cache in DbalMapper; thanks @matej21 [0dd82ca]
  • v2.2.1 2.2.1

    Stable patch version 2.2.1 is out! ๐Ÿฅ What's changed from 2.2.0?

    • fixed bug when derived relationship would cause loading whole relationship during persist [b56a1a0]
    • fixed bug in null & date time comparison [eeff907]
price-tag-2-line

Badges

guide-fill

Dependencies

php (>=7.1)
nette/caching (~2.5 || ~3.0@rc)
nette/utils (~2.5 || ~3.0@rc)
nette/tokenizer (~2.3 || ~3.0@rc)
nextras/dbal (~3.0 || ~3.1@dev)
Componette Componette felix@nette.org