Download the PHP package wscore/decaorm without Composer

On this page you can find all versions of the php package wscore/decaorm. 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 decaorm

DecaORM

DecaORM is a simple, lightweight data-mapper ORM for PHP 8. It uses PHP 8 attributes to map entity classes to database tables and provides flexible data access via the repository pattern.

Support

PHP: 8.1, 8.2, 8.3, 8.4
Databases: SQLite, MySQL, PostgreSQL


Features

Not supported

License

MIT License

Installation

Install with Composer:

Documentation

Japanese: Repository hooks

⚠ Raw API safety

whereRaw, havingRaw, joinRaw, withRaw, fromRaw, setRaw, selectRaw, and orderByRaw append SQL fragments as-is. DecaORM does not apply SQL injection protections to these methods.


Quick start

1. Define an entity

Use attributes from WScore\DecaORM\Attribute and implement EntityInterface with EntityTrait.

See entity-en.md for property types and attributes.

2. Implement a repository

Extend AbstractRepository for your entity.

3. Basic CRUD


Relations

Relations are not loaded automatically. Call load() explicitly or use lazy loading in getters.

Parent entity (e.g. User)

Child entity (e.g. Post)

Lazy loading

Calling load($relationName) in a getter loads the relation on first access and returns the cached value afterward.

Associating relations with associate()

Use the public API associate($relationName, $targetOrTargets) to set relations. DecaORM updates FKs and inverse references accordingly.

Note: associate() only updates in-memory links. For ManyToMany, call the repository’s syncManyToMany($entity, $relationName) to persist the join table.

Batch loading (avoiding N+1)

Load a relation for many entities in one query.

EntityCollection

Use the collection for filtering, batch loading, and saving.

Many-to-many

Many-to-many uses a join table. Specify the table and column names in the #[ManyToMany] attribute (no separate entity/repository for the join table).

Loading: use $user->load('roles') or batch load: $users->load('roles').

Syncing: use ManyToManyTrait in the repository and call syncManyToMany() after changing the relation on the entity. It will INSERT/DELETE rows in the join table as needed.

Polymorphic (Morph) relations

When a child row can point to more than one parent type (e.g. a comment on either a post or a video), use:

Loading the morph parent from the child returns a generic Collection, not EntityCollection, because parent instances may belong to different classes. Parents are resolved per child row. There is no extra method on RepositoryInterface; inverse queries are built in MappedByQuery using the usual repository API.

See README-ja.md (Japanese) for a longer explanation and examples.


Saving and dependency order

DecaORM has no Unit of Work. You must save in dependency order (e.g. parent before children).

Example with transaction:

Default container (once at app bootstrap)

Per-request container (e.g. multi-tenant)

OrmManager resolves PDO::class and repository entries from the single container passed to initialize(). After you know the tenant, build a container that already holds that tenant’s PDO (and repositories), then call OrmManager::initialize($container) for that request—or inject an OrmManager constructed for that container. For more than one connection in the same process, use separate OrmManager instances (each has its own identity map and dirty tracker); nested container scopes are not supported.


Summary of limitations

  1. Save order — No UoW; save parents before children.
  2. Transactions — Use them when saving multiple entities.
  3. Relations — Never auto-loaded; call load() when needed.
  4. Foreign keys — Use DB constraints for integrity.
  5. New vs update — Determined by presence of ID; you can also call insertEntity() or updateEntity() explicitly.

All versions of decaorm with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-pdo Version *
psr/container Version ^1.0 || ^2.0
psr/log Version ^3.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 wscore/decaorm contains the following files

Loading the files please wait ...