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(6mo ago)082MITPHP

Since Dec 9Pushed 2mo agoCompare

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

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

30

—

LowBetter than 62% of packages

Maintenance77

Regular maintenance activity

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

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

206d 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

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)

PHPackages © 2026

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