PHPackages                             pepperfm/ssd-for-laravel - 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. pepperfm/ssd-for-laravel

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

pepperfm/ssd-for-laravel
========================

Simple Slim DTO

1.0.5(1mo ago)035.6k↓53%1MITPHPPHP ^8.4CI passing

Since Feb 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/pepperfm/ssd-for-laravel)[ Packagist](https://packagist.org/packages/pepperfm/ssd-for-laravel)[ Docs](https://github.com/pepperfm/ssd-for-laravel)[ RSS](/packages/pepperfm-ssd-for-laravel/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (13)Versions (23)Used By (1)

Simple Slim DTO
===============

[](#simple-slim-dto)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ad1bf11cc4738a6322dff8207494e795ce07c6009b33dc024294f47999328d1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706570706572666d2f7373642d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pepperfm/ssd-for-laravel)[![Total Downloads on Packagist](https://camo.githubusercontent.com/7926de4999dc1cc55ee1d09aeb050fc1b587f4d04931f816f77aba4c67f47fe8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706570706572666d2f7373642d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pepperfm/ssd-for-laravel)[![GitHub Actions](https://github.com/pepperfm/ssd-for-laravel/actions/workflows/main.yml/badge.svg)](https://github.com/pepperfm/ssd-for-laravel/actions/workflows/main.yml/badge.svg)

Simple Slim DTO helps you describe small DTO classes for Laravel responses, array payloads, and typed data wrappers.

The package maps array-like input into public typed properties, supports snake\_case and camelCase keys, casts nested DTOs, converts iterable items, and serializes DTOs back to arrays or JSON.

Tip

[Full Package Description](https://docs.pepperfm.com/simple-slim-dto)

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

[](#requirements)

- PHP `^8.4`

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

[](#installation)

```
composer require pepperfm/ssd-for-laravel
```

Basic Usage
-----------

[](#basic-usage)

Extend `BaseDto` and describe the payload with public typed properties.

```
use Pepperfm\Ssd\BaseDto;

class ResponseWrapperDto extends BaseDto
{
    public array $data;

    public LinksDto $links;

    public MetaDto $meta;
}
```

Create DTOs from arrays, objects, `Arrayable`, `Traversable`, or named arguments.

```
$dto = ResponseWrapperDto::make([
    'data' => $response['data'],
    'links' => $response['links'],
    'meta' => $response['meta'],
]);
```

```
$dto = new ResponseWrapperDto(
    data: $response['data'],
    links: $response['links'],
    meta: $response['meta'],
);
```

Nested DTO properties are cast automatically.

```
use Pepperfm\Ssd\BaseDto;

class LinksDto extends BaseDto
{
    public ?string $first = null;

    public ?string $last = null;

    public ?string $prev = null;

    public ?string $next = null;
}

class MetaDto extends BaseDto
{
    public int $currentPage;

    public int $total;
}
```

Iterable Casting
----------------

[](#iterable-casting)

Use `ToIterable` when a property contains a list of items.

The first argument is the collection type. Use `ToIterable::ARRAY` for a native array. The second argument is optional and defines the item type.

```
use Pepperfm\Ssd\Attributes\ToIterable;
use Pepperfm\Ssd\BaseDto;

class ResponseDataDto extends BaseDto
{
    public string $id;

    public string $name;
}

class ResponseWrapperDto extends BaseDto
{
    #[ToIterable(ToIterable::ARRAY, ResponseDataDto::class)]
    public array $data = [];
}
```

```
/** @var array $items */
$items = $dto->data;
```

For Laravel collections, pass the collection class as the first argument.

```
use Illuminate\Support\Collection;
use Pepperfm\Ssd\Attributes\ToIterable;
use Pepperfm\Ssd\BaseDto;

class ResponseWrapperDto extends BaseDto
{
    #[ToIterable(Collection::class, ResponseDataDto::class)]
    public Collection $data;
}
```

```
/** @var Collection $items */
$items = $dto->data;
```

If the item type is omitted, iterable items are kept as-is.

```
use Pepperfm\Ssd\Attributes\ToIterable;
use Pepperfm\Ssd\BaseDto;

class TagsDto extends BaseDto
{
    #[ToIterable(ToIterable::ARRAY)]
    public array $tags = [];
}
```

The item type may be another `BaseDto` class or any class that can be instantiated from one value.

Key Mapping
-----------

[](#key-mapping)

Input keys can be camelCase or snake\_case. Output keys are camelCase by default. Use `MapName` when the external key must be explicit.

```
use Pepperfm\Ssd\Attributes\MapName;
use Pepperfm\Ssd\BaseDto;

class UserDto extends BaseDto
{
    #[MapName('external_name')]
    public string $displayName;
}
```

```
$dto = UserDto::make([
    'external_name' => 'Ada',
]);

$dto->displayName; // Ada
$dto->external_name; // Ada
$dto->toArray(); // ['external_name' => 'Ada']
```

Collections and Helpers
-----------------------

[](#collections-and-helpers)

Convert many payloads into DTO instances with `collect()`.

```
$items = ResponseDataDto::collect($response['data']);
```

Use `only()` and `except()` on serialized DTO output.

```
$dto->only('data', 'meta');
$dto->except('links');
```

Serialization
-------------

[](#serialization)

```
$dto->toArray();
$dto->jsonSerialize();
json_encode($dto);
```

Testing
-------

[](#testing)

```
composer test
composer lint
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Dmitry Gaponenko](https://pepperfm.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance90

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Recently: every ~0 days

Total

22

Last Release

47d ago

Major Versions

0.2.0 → 1.0.02026-07-03

PHP version history (2 changes)0.0.3PHP ^8.2

1.0.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36007880?v=4)[Dmitry](/maintainers/PepperFM)[@pepperfm](https://github.com/pepperfm)

---

Top Contributors

[![pepperfm](https://avatars.githubusercontent.com/u/36007880?v=4)](https://github.com/pepperfm "pepperfm (43 commits)")

---

Tags

schematypehintSimpledtopepperfmssd-for-laravel

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pepperfm-ssd-for-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/pepperfm-ssd-for-laravel/health.svg)](https://phpackages.com/packages/pepperfm-ssd-for-laravel)
```

###  Alternatives

[simplesoftwareio/simple-qrcode

Simple QrCode is a QR code generator made for Laravel.

2.9k31.6M124](/packages/simplesoftwareio-simple-qrcode)[league/config

Define configuration arrays with strict schemas and access values with dot notation

567347.0M41](/packages/league-config)[rinvex/countries

Rinvex Countries is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

1.7k8.2M65](/packages/rinvex-countries)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49863.5M114](/packages/marc-mabe-php-enum)[torann/json-ld

Extremely simple JSON-LD markup generator.

152648.0k1](/packages/torann-json-ld)[brick/schema

Schema.org library for PHP

5293.6k1](/packages/brick-schema)

PHPackages © 2026

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