PHPackages                             kyserbyte/ypd - 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. kyserbyte/ypd

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

kyserbyte/ypd
=============

Ypd Php Decorator implements "decorators/annotations and meta-programming" in PHP, via doc comments.

v0.1.0(6y ago)09MITPHPPHP &gt;=5.4

Since Jun 30Pushed 6y agoCompare

[ Source](https://github.com/Kyserbyte/ypd)[ Packagist](https://packagist.org/packages/kyserbyte/ypd)[ RSS](/packages/kyserbyte-ypd/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

YPD - **Y**pd **P**hp **D**ecorator
===================================

[](#ypd---ypd-php-decorator)

Ypd Php Decorator implements "decorators/annotations and meta-programming" in PHP, via doc comments.

INSTALL
-------

[](#install)

You can install the package with composer: `composer require kyserbyte/ypd`

USAGE
-----

[](#usage)

At the monent is implemented only the `ypd::jsonSerialize` decorator. To *activate* the decorator you have to implement the `JsonSerializable` interface in the class that you want to make *json serializable* via the decorator. Then you have to add the `YPDJsonSerializer` trait to your class. This trait has an internal implementation of the method `jsonSerialize()` required by the `JsonSerializable` interface, so you need only to declare the `implements` statement in you class. Now you are able to use the decorator inside a doc comment, in order to declare what properties you want to *expose* to json. The decorator works for now only with the public properties of a class.

### jsonSerialize decorator

[](#jsonserialize-decorator)

Inside a doc comment over your property, you need to declare the decorator with the syntax

```
/**
* ypd::jsonSerialize(name=XX,if=YY)
*/
public $propName;

```

with the declaration you can pass 2 arguments to the decorator.

- **name**: specify a custom name for the property when exported to json
- **if**: a Function that resolve to boolean. You can use it to implement a conditional logic for export the property. The Function must be declared in the same class of the property or in a trait used by the class and must be public.

Take a look to [DemoJsonSerialize](demo/DemoJsonSerialize.php) class for more info about usage.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

2511d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ff623dba359760aaf22c07823d306adf3a13e05aae764feca1579f38ccfa31a?d=identicon)[Kyserbyte](/maintainers/Kyserbyte)

---

Top Contributors

[![Kyserbyte](https://avatars.githubusercontent.com/u/25266591?v=4)](https://github.com/Kyserbyte "Kyserbyte (10 commits)")

---

Tags

phpannotationdecoratormeta programming

### Embed Badge

![Health badge](/badges/kyserbyte-ypd/health.svg)

```
[![Health](https://phpackages.com/badges/kyserbyte-ypd/health.svg)](https://phpackages.com/packages/kyserbyte-ypd)
```

###  Alternatives

[hyperf/di

A DI for Hyperf.

182.8M594](/packages/hyperf-di)[marcin-orlowski/lombok-php

Never write boilerplate code for your data class again!

3118.6k1](/packages/marcin-orlowski-lombok-php)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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