PHPackages                             phpstream/objective - 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. phpstream/objective

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

phpstream/objective
===================

Simple domain transfer objects.

0.0.1(5mo ago)080MITPHP

Since Dec 9Pushed 4mo agoCompare

[ Source](https://github.com/phpstream/objective)[ Packagist](https://packagist.org/packages/phpstream/objective)[ RSS](/packages/phpstream-objective/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

[![banner](./assets/banner.png)](./assets/banner.png)

Installation
============

[](#installation)

`composer require phpstream/objective`

Example Setup
-------------

[](#example-setup)

```
use Phpstream\Objective\Traits\Objective;
use Symfony\Component\Validator\Constraints;

class Comment
{
    use Objective;

    #[Constraints\NotBlank]
    #[Constraints\Length(min: 6)]
    public string $message;
}
```

```
use Phpstream\Objective\Traits\Objective;
use Symfony\Component\Validator\Constraints;

class Post
{
    use Objective;

    #[Constraints\NotBlank]
    #[Constraints\Length(min: 12)]
    public string $title;

    #[Constraints\NotBlank]
    #[Constraints\Length(min: 128)]
    public string $body;

    /** @var array */
    public array $comments = [];
}
```

Constraints are optional. See [Symfony Validation Documentation](https://symfony.com/doc/current/validation.html#constraints) for available constraints.

Deserialization
---------------

[](#deserialization)

```
$array = [
    'title' => 'Hello World',
    'body' => 'Salutations!',
    'comments' => [
        ['message' => 'First!'],
        ['message' => 'Second!']
    ],
];

/* make from array  */ $post = Post::make($array);
/* make from object */ $post = Post::make($post->toObject());
/* make from JSON   */ $post = Post::make($post->toJson());
/* make from YAML   */ $post = Post::make($post->toYaml());
```

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

[](#serialization)

```
use Phpstream\Objective\Enums\Output;

/* serialize to array  */ $array  = $post->toArray();
/* serialize to object */ $object = $post->toObject();
/* serialize to JSON   */ $json   = $post->toJson();
/* serialize to YAML   */ $yaml   = $post->toYaml();

// OR

/* serialize to array  */ $array  = $post->to(Output::Array);
/* serialize to object */ $object = $post->to(Output::Object);
/* serialize to JSON   */ $json   = $post->to(Output::JSON);
/* serialize to YAML   */ $yaml   = $post->to(Output::YAML);
```

Validation
----------

[](#validation)

```
$validation = Post::validate([
    'title' => 'This title is way too long for the validation rule...',
    'body'  => 'This body is way too short for the validation rule...',
]);

if ($validation->fails())
   foreach($validation->errors() as $error)
      echo "$error->getProperty(): $error->getMessage()";
```

You may also validate from serialization formats.

```
/* Or validate from other data formats */
$post = Post::make($input);

/* validate from class  */ $validation = Post::validate($post);
/* validate from object */ $validation = Post::validate($post->toObject());
/* validate from JSON   */ $validation = Post::validate($post->toJson());
/* validate from YAML   */ $validation = Post::validate($post->toYaml());
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance75

Regular maintenance activity

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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

160d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1300442?v=4)[Stephen Lake](/maintainers/stephenlake)[@stephenlake](https://github.com/stephenlake)

---

Top Contributors

[![stephenlake](https://avatars.githubusercontent.com/u/1300442?v=4)](https://github.com/stephenlake "stephenlake (26 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/phpstream-objective/health.svg)

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

###  Alternatives

[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[pixelopen/cloudflare-turnstile-bundle

A simple package to help integrate Cloudflare Turnstile on Symfony.

31205.8k3](/packages/pixelopen-cloudflare-turnstile-bundle)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)[mapbender/mapbender

Mapbender library

10117.4k5](/packages/mapbender-mapbender)[symfony/ux-cropperjs

Cropper.js integration for Symfony

19280.3k3](/packages/symfony-ux-cropperjs)

PHPackages © 2026

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