Download the PHP package elriseio/dto-entity-updater without Composer

On this page you can find all versions of the php package elriseio/dto-entity-updater. 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 dto-entity-updater

Entity Updater Bundle

Reusable Symfony 7.2 bundle that applies a DTO-shaped payload to a Doctrine entity while distinguishing leave unchanged from set to default via the Placeholder sentinel pattern.

What problem this solves

Updating a Doctrine entity from a typed DTO looks simple until the DTO has a field the caller wants to leave alone. Three workarounds exist, and each fails differently. A per-field isset($dto->field) chain works for nullable DTOs but doubles the boilerplate of every update. A null sentinel works for nullable fields and silently corrupts typed ones (int, string, float, array), because PHP will not accept null for a non-nullable typed property. A "default value" sentinel — e.g. 0 for int or '' for string — looks safe until a host invents its own sentinel that does not match the bundle's, and the comparison $value !== $default then treats "leave unchanged" as "set to default", silently overwriting fields the caller meant to keep (see RUNBOOK §F3).

That is the failure mode this bundle prevents: a typed DTO round-trip that silently mutates a Doctrine row into a placeholder default.

How this bundle solves it

The bundle ships a small Placeholder value holder with one sentinel constant per primitive type — Placeholder::NONE_INT, NONE_STRING, NONE_FLOAT, NONE_ARRAY — and a Placeholder::NONE_DEFAULT that triggers type-based default resolution. A DTO declares the right sentinel as its "unset" default; the updater compares each incoming field to the per-type sentinel using reflection on the entity setter's declared parameter type, so the caller never has to specify per-field which sentinel applies. The full per-type table and === comparison semantics live in the entity-update contract.

Two implementers expose the same sentinel logic with deliberately different strictness, so callers can pick the one that matches their context:

A 5-line DTO plus a one-line handler call is enough to make both paths work:

For the overall picture — Domain / Infrastructure layering, captured trade-offs, and the role of the sentinel pattern — see docs/architecture.md. For the full public contract, deprecation policy, and Placeholder value stability rules, see docs/contracts/entity-update-contract.md.

Minimum requirements

Installation

The package is published on Packagist as elriseio/dto-entity-updater and can be installed via Composer:

Register the bundle in config/bundles.php if Symfony Flex did not do it automatically:

The bundle exposes no configuration keys today; the dto_entity_updater.* namespace is reserved for the optional DefaultResolver cache toggle (see docs/perf.md).

Usage

Service: DtoEntityUpdater (lenient)

Unknown fields (no setter, no getter, unrecognised setter type) are silently skipped and an info log is emitted via PSR-3 (see CR-002-IMPL-12).

Trait: RepositoryHelperTrait (strict)

In your Doctrine repository, implement RepositoryInterface and use the trait:

Missing accessors throw InvalidArgumentException; reflection failures throw LogicException (see CR-002-IMPL-01).

Sentinels: Placeholder

Declare a DTO field's "unset" default as the matching sentinel:

The full per-type table is in entity-update-contract §2.

Testing

The bundle ships with PHPUnit, PHPStan, php-cs-fixer, and phpbench. All four are wired through composer scripts:

Domain purity is enforced separately by scripts/check_domain_purity.sh:

A CI workflow (.github/workflows/ci.yml) runs all of the above on every push and pull request against develop / master / v2-updates.

Performance

For hot-path characteristics and the CachedDefaultResolver opt-in, see docs/perf.md. TL;DR: PHP 8.3+ reflection is fast enough that the cache only pays off for long-running worker processes; the default config (no cache) is correct for typical PHP-FPM workloads.

License

Proprietary. See LICENSE for the full text. For licensing enquiries, contact [email protected].

Changelog

See CHANGELOG.md for the per-version change history. The 1.1.0 entry enumerates the Bug-1/2/3 fixes, the DI modernisation, the test infrastructure scaffold, the DefaultResolver extraction, and the cache opt-in.


All versions of dto-entity-updater with dependencies

PHP Build Version
Package Version
Requires php Version ~8.3
symfony/config Version ^7.2
symfony/dependency-injection Version ^7.2
symfony/http-kernel Version ^7.2
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 elriseio/dto-entity-updater contains the following files

Loading the files please wait ...