PHPackages                             hided62/ldto - 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. hided62/ldto

ActiveLibrary

hided62/ldto
============

php lightweight dto library

v1.0.1(3y ago)1117↓100%MITPHPPHP &gt;=8.1

Since Aug 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/hided62/ldto)[ Packagist](https://packagist.org/packages/hided62/ldto)[ Docs](https://github.com/hided62/ldto)[ RSS](/packages/hided62-ldto/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (3)Used By (0)

LDTO
====

[](#ldto)

A lightweight DTO library inspired by `spatie/data-transfer-object`.

- Attribute based
- Built-in Enum conversion
- No external dependency

Install
-------

[](#install)

`composer require hided62/ldto`

Example
-------

[](#example)

```
use LDTO\Attr\Convert;
use LDTO\Attr\JsonString;
use LDTO\Attr\NullIsUndefined;
use LDTO\Attr\RawName;
use LDTO\Converter\DateTimeConverter;

enum AuctionType: string
{
    case GamePoint = 'point';
    case UniqueItem = 'item';
}

enum ResourceType: string
{
    case GamePoint = 'point';
    case Gold = 'gold';
}

class AuctionInfo extends \LDTO\DTO
{
    public function __construct(
        #[NullIsUndefined]
        public ?int $id,
        public AuctionType $type,
        public bool $finished,
        public ?string $target,
        #[RawName('host_id')]
        public int $hostID,
        #[RawName('req_resource')]
        public ResourceType $reqResource,

        #[RawName('open_date')]
        #[Convert(DateTimeConverter::class)]
        public \DateTimeImmutable $openDate,
        #[RawName('close_date')]
        #[Convert(DateTimeConverter::class)]
        public \DateTimeImmutable $closeDate,

        #[JsonString]
        public AuctionInfoDetail $detail,
    ) {
    }
}

class AuctionInfoDetail extends \LDTO\DTO
{
    public function __construct(
        public string $title,
        public string $hostName,
        public int $amount,

        public int $startBidAmount,
        #[NullIsUndefined]
        public ?int $finishBidAmount,
        #[NullIsUndefined]
        public ?int $remainCloseDateExtensionCnt,
        #[NullIsUndefined]
        #[Convert(DateTimeConverter::class)]
        public ?\DateTimeImmutable $availableLatestBidCloseDate,
    ) {
    }
}

class AuctionBidItem extends \LDTO\DTO
{
    public function __construct(
        #[NullIsUndefined]
        public ?int $no,
        #[RawName('auction_id')]
        public int $auctionID,

        #[RawName('bidder_id')]
        public int $bidderID,

        public int $amount,

        #[Convert(DateTimeConverter::class)]
        public \DateTimeImmutable $date,
        #[JsonString]
        public AuctionBidItemData $aux,
    ) {
    }
}

class AuctionBidItemData extends \LDTO\DTO
{
    public function __construct(
        public string $bidderName,
        #[NullIsUndefined]
        public ?string $message,
    ) {
    }
}

function example1(DB $db, int $auctionID): AuctionInfo
{
    $raw = $db->queryFirstRow('SELECT * FROM `auction` WHERE id = %i', $auctionID);
    $auction = AuctionInfo::fromArray($raw);

    $date = new DateTimeImmutable();
    $auction->closeDate = $date;
    $auction->finished = true;

    $db->update('auction', $auction->toArray('id'), 'id = %i', $auction->id);
    return $auction;
}

function example2(DB $db, int $auctionID, User $user, int $amount, ?string $msg): void
{
    $newBid = new AuctionBidItem(
        null,
        $auctionID,
        $user->id,
        $amount,
        new DateTimeImmutable(),
        new AuctionBidItemData(
            $user->name,
            $msg,
        )
    );
    $db->insert('auction_bid', $newBid->toArray());
}
```

###  Health Score

27

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~210 days

Total

2

Last Release

1115d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/367ff6ca9430ee0d76f1e870711feee60eb03d502abd45261777dcfb23626e3d?d=identicon)[hided62](/maintainers/hided62)

---

Top Contributors

[![hided62](https://avatars.githubusercontent.com/u/28426029?v=4)](https://github.com/hided62 "hided62 (11 commits)")

---

Tags

serializedata-transfer-objectlightweightdtohided62

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hided62-ldto/health.svg)

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

###  Alternatives

[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

751543.1k12](/packages/wendelladriel-laravel-validated-dto)[cerbero/dto

Data Transfer Object (DTO)

17118.7k1](/packages/cerbero-dto)[yorcreative/laravel-argonaut-dto

Argonaut is a lightweight Data Transfer Object (DTO) package for Laravel that supports nested casting, recursive serialization, and validation out of the box. Ideal for service layers, APIs, and clean architecture workflows.

1042.4k1](/packages/yorcreative-laravel-argonaut-dto)[friendsofhyperf/validated-dto

The Data Transfer Objects with validation for Hyperf.

1412.2k](/packages/friendsofhyperf-validated-dto)[event4u/data-helpers

Framework-agnostic PHP library for data mapping, DTOs and utilities. Includes DataMapper, SimpleDto/LiteDto, DataAccessor/Mutator/Filter and helper classes (MathHelper, EnvHelper, etc.). Works with Laravel, Symfony/Doctrine or standalone PHP.

1411.8k](/packages/event4u-data-helpers)

PHPackages © 2026

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