PHPackages                             zero-to-prod/dynamic-setter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zero-to-prod/dynamic-setter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zero-to-prod/dynamic-setter
===========================

Fluently set class properties with dynamic methods.

v71.2.0(8mo ago)11.9k3MITDockerfilePHP &gt;=7.1CI passing

Since Sep 5Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/zero-to-prod/dynamic-setter)[ Packagist](https://packagist.org/packages/zero-to-prod/dynamic-setter)[ Docs](https://github.com/zero-to-prod/dynamic-setter)[ Fund](https://github.com/sponsors/zero-to-prod)[ RSS](/packages/zero-to-prod-dynamic-setter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (3)

Zerotoprod\\DynamicSetter
=========================

[](#zerotoproddynamicsetter)

[![](./art/logo.png)](./art/logo.png)

[![Repo](https://camo.githubusercontent.com/9a90a3efeee26aed7d7f2feee9cd84566a26f9c362cc773b184d076210906e1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d677261793f6c6f676f3d676974687562)](https://github.com/zero-to-prod/dynamic-setter)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/c20433e017954bf72c05aff924181680b27a81500550aa7f93f847034506537a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f64796e616d69632d7365747465722f746573742e796d6c3f6c6162656c3d74657374)](https://github.com/zero-to-prod/dynamic-setter/actions)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/acbed49e8dea6ecb056ee148cfe45c17ffb16ebc23bbb45a0022bd653b537f0a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f64796e616d69632d7365747465722f6261636b77617264735f636f6d7061746962696c6974792e796d6c3f6c6162656c3d6261636b77617264735f636f6d7061746962696c697479)](https://github.com/zero-to-prod/dynamic-setter/actions)[![Packagist Downloads](https://camo.githubusercontent.com/80c8975dc9c3976fc10da912c1041c31fe6fb3918fa2bb09ebf0bcf4d5ca0370/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a65726f2d746f2d70726f642f64796e616d69632d7365747465723f636f6c6f723d626c7565)](https://packagist.org/packages/zero-to-prod/dynamic-setter/stats)[![Packagist Version](https://camo.githubusercontent.com/6507fffdbe4ae24d322dd20662c44be0f18b5eee257c8a8a86932c204d94c773/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a65726f2d746f2d70726f642f64796e616d69632d7365747465723f636f6c6f723d663238643161)](https://packagist.org/packages/zero-to-prod/dynamic-setter)[![GitHub repo size](https://camo.githubusercontent.com/cc8554774bc75aac1959ba4636b059267e2c9ef85b52ae5c2272c6db2b669b1e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f7a65726f2d746f2d70726f642f64796e616d69632d736574746572)](https://github.com/zero-to-prod/dynamic-setter)[![License](https://camo.githubusercontent.com/c7f369bc40912e1efa3d7de6ba40238206c4fd90277b96ccb95da30c7d558f87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a65726f2d746f2d70726f642f64796e616d69632d7365747465723f636f6c6f723d726564)](https://github.com/zero-to-prod/dynamic-setter/blob/main/LICENSE.md)[![Hits-of-Code](https://camo.githubusercontent.com/5efc039cc404bc5039f63a7529f01c9c5c47c16627cfdeb1e3b88c9346b8832d/68747470733a2f2f686974736f66636f64652e636f6d2f6769746875622f7a65726f2d746f2d70726f642f64796e616d69632d7365747465723f6272616e63683d6d61696e)](https://hitsofcode.com/github/zero-to-prod/dynamic-setter/view?branch=main)

Contents
--------

[](#contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Documentation Publishing](#documentation-publishing)
    - [Automatic Documentation Publishing](#automatic-documentation-publishing)
- [Usage](#usage)
    - [Nested Objects](#nested-objects)
- [Local Development](./LOCAL_DEVELOPMENT.md)
- [Contributing](#contributing)

Introduction
------------

[](#introduction)

Fluently set class properties with dynamic methods.

Requirements
------------

[](#requirements)

- PHP 7.1 or higher.

Installation
------------

[](#installation)

Install `Zerotoprod\DynamicSetter` via [Composer](https://getcomposer.org/):

```
composer require zero-to-prod/dynamic-setter
```

This will add the package to your project's dependencies and create an autoloader entry for it.

Documentation Publishing
------------------------

[](#documentation-publishing)

You can publish this README to your local documentation directory.

This can be useful for providing documentation for AI agents.

This can be done using the included script:

```
# Publish to default location (./docs/zero-to-prod/dynamic-setter)
vendor/bin/zero-to-prod-dynamic-setter

# Publish to custom directory
vendor/bin/zero-to-prod-dynamic-setter /path/to/your/docs
```

### Automatic Documentation Publishing

[](#automatic-documentation-publishing)

You can automatically publish documentation by adding the following to your `composer.json`:

```
{
    "scripts": {
        "post-install-cmd": [
            "zero-to-prod-dynamic-setter"
        ],
        "post-update-cmd": [
            "zero-to-prod-dynamic-setter"
        ]
    }
}
```

Usage
-----

[](#usage)

The `DynamicSetter` trait allows you to easily create class instances and dynamically set properties through method chaining. It provides a simple way to manage object instantiation and property setting with `set_*` methods.

To use the `DynamicSetter` trait, include it in your class and define the properties you want to set dynamically.

```
use Zerotoprod\StreamContext\DynamicSetter;

class User
{
    use DynamicSetter;

    public $name;
    public $email;
}

$user = User::new()
    ->set_name('John Doe')
    ->set_email('john.doe@example.com');

echo $user->name;  // Output: John Doe
echo $user->email; // Output: john.doe@example.com
```

### Nested Objects

[](#nested-objects)

You can also use the DynamicSetter trait in classes that contain other objects, allowing you to set properties in a nested structure.

```
class Address
{
    use DynamicSetter;

    public $city;
    public $postalCode;
}

class Customer
{
    use DynamicSetter;

    public $name;
    public $address;
}

$customer = Customer::new()
    ->set_name('Jane Doe')
    ->set_address(
        Address::new()
            ->set_city('New York')
            ->set_postalCode('10001')
    );

echo $customer->name;                   // Output: Jane Doe
echo $customer->address->city;          // Output: New York
echo $customer->address->postalCode;    // Output: 10001
```

Contributing
------------

[](#contributing)

Contributions, issues, and feature requests are welcome! Feel free to check the [issues](https://github.com/zero-to-prod/dynamic-setter/issues) page if you want to contribute.

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Commit changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Create a new Pull Request.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance60

Regular maintenance activity

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~30 days

Recently: every ~58 days

Total

13

Last Release

252d ago

PHP version history (2 changes)v71.0.0PHP ^7.1

v71.0.3PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/502649f05d36c87d494988bd99193a4d908d345335d99c080928a726277371f5?d=identicon)[zero-to-prod](/maintainers/zero-to-prod)

---

Top Contributors

[![zero-to-prod](https://avatars.githubusercontent.com/u/61474950?v=4)](https://github.com/zero-to-prod "zero-to-prod (15 commits)")

---

Tags

dtophpzero-to-proddynamic-setter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zero-to-prod-dynamic-setter/health.svg)

```
[![Health](https://phpackages.com/badges/zero-to-prod-dynamic-setter/health.svg)](https://phpackages.com/packages/zero-to-prod-dynamic-setter)
```

###  Alternatives

[zero-to-prod/data-model

Transforms Data into Type-Safe DTOs.

14226.2k32](/packages/zero-to-prod-data-model)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
