Download the PHP package ez-php/orm without Composer

On this page you can find all versions of the php package ez-php/orm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package orm

ez-php/orm

ORM module for the ez-php framework — Data Mapper pattern with Entity, AbstractRepository, a fluent QueryBuilder, and a Schema builder.

CI

Requirements

Installation

Setup

Register the service providers:

Usage

Defining an entity

Defining a repository

Persisting

Querying

Large result sets: chunk() pages with LIMIT/OFFSET. chunkById() and lazy() page by key instead (WHERE id > last ORDER BY id) — every page costs the same, and rows the callback updates or deletes do not make later pages skip or repeat rows. Both keep the query's where() clauses and the soft-delete filter; the key column (default id) must be unique and selected:

Column names are validated and quoted in every clause. having() and select() take a plain column or one aggregate over a column or * — COUNT, SUM, AVG, MIN, MAX, optionally DISTINCT (select() also accepts AS alias). For any other SQL expression use selectRaw(), which is emitted verbatim — never pass user input to it:

Soft deletes

Relations

Define relation helpers on the repository, then call them on an entity. Each helper takes the related repository instance, the key columns and the owning entity's key value:

with() already loads a relation for a whole result set in one query. If you instead access relations lazily inside a loop, RelationBatcher (requires ez-php/dataloader) collapses those per-entity queries into one per relation:

hasOne(), hasMany() and belongsToMany() work the same way (hasMany/belongsToMany resolve to a list, empty when there are none). belongsToMany() loads every queued owner through one pivot join:

Custom casts

Entity lifecycle observers

Attach observers to a repository to react to create/update/delete events:

The *ing hooks fire before the DB operation; *ed hooks fire after.

Append-only repositories

For insert-only tables (audit logs, event logs, immutable records) extend AppendOnlyRepository instead of AbstractRepository. create() inserts and returns the entity with its generated primary key; save() and delete() throw LogicException, so the constraint is enforced by the type rather than by convention.

Typed attribute getters

Entity::getAttribute() returns mixed. Use the TypedAttributes trait for typed access that satisfies PHPStan level 9 without per-call narrowing:

getInt()/getString() fall back to a default for non-numeric/non-scalar values; getNullableDatetime() parses Y-m-d H:i:s and returns null otherwise.

Schema builder

Query logging

LoggingDatabase decorates any DatabaseInterface and logs SQL + bindings + duration for every query()/execute() call via ez-php/logging (a soft dependency — install it separately, since it's declared in require-dev here, not require):

Opt-in only — wrap the connection you pass in yourself; nothing logs by default.

Console commands

Command Description
make:entity Scaffolds an Entity subclass in app/Entities/
make:repository Scaffolds an AbstractRepository subclass in app/Repositories/

Both are registered automatically by EntityServiceProvider::boot() when the application implements CommandRegistryInterface (the ez-php Application does). They write relative to the working directory (<cwd>/app/…) — run php ez from the project root.

Classes

Class Description
Entity Abstract Data Mapper entity base; attributes, casts, fillable guards, relation storage
AbstractRepository Abstract repository base; INSERT/UPDATE/DELETE, dirty tracking, relations, eager-load
AppendOnlyRepository Repository base for insert-only tables (audit/event logs): create() inserts; save()/delete() throw LogicException
TypedAttributes Trait adding getInt()/getString()/getBool()/getNullableInt()/getNullableString()/getNullableDatetime() to an entity
EntityObserverInterface Lifecycle hook contract: creating/created/updating/updated/deleting/deleted
ObservableRepositoryTrait Adds observer support to a repository; fires hooks around save() and delete()
EntityQueryBuilder Typed fluent query builder for entities; with(), withCount(), paginate(), chunk()/chunkById()/lazy()
EntityServiceProvider Calls Entity::setDatabase($db) in boot(); registers make:entity / make:repository
Hydrator Converts raw DB rows → Entity instances and Entity attributes → storage arrays
CastableInterface Interface for custom value-object casts: castFrom()/castTo()
DuplicateKeyException Thrown on duplicate-key violations by QueryBuilder::insert()/insertBatch() and therefore by repository save() (original PDOException is getPrevious())
Paginator Immutable page-of-results value object
QueryBuilder Fluent SQL builder for raw rows; all WHERE/JOIN/ORDER/LIMIT/aggregates/paginate/chunk/chunkById/lazy/cache
LoggingDatabase DatabaseInterface decorator logging SQL + bindings + duration
EntityHasMany One-to-many relation (FK on related entity)
EntityHasOne One-to-one relation (FK on related entity)
EntityBelongsTo Inverse of HasMany/HasOne (FK on owning entity)
EntityBelongsToMany Many-to-many relation via pivot table
Schema DDL façade: create(), table(), drop(), dropIfExists(), hasTable()
Blueprint Column and constraint builder for CREATE TABLE and ALTER TABLE

License

MIT — Andreas Uretschnig


All versions of orm with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ez-php/contracts Version ^2.7.0
ez-php/console Version ^2.7.0
ez-php/cache Version ^2.7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ez-php/orm contains the following files

Loading the files please wait ...