Skip to content

u/yuriizee

In this archive from Jul 2026 to Dec 2026

4
posts
25
comments
1
media
32
score
7 saved before deletion

So what? Is it illegal?

It seems to me that AI either took your job, or you’re just a hardcore AI hater who can’t accept the direction of digital progress.

We live in a modern era where IT has been undergoing transformation for years, and most forward-thinking companies have already integrated AI into their day-to-day processes and development workflows.

And that’s a good thing. AI is a powerful tool, and sooner or later every company will use it in one way or another.

Some people will vibe-code through prompts. Others will build sophisticated SDD workflows. Some will choose a hybrid approach or something completely different. But eventually, everyone will have to adapt to it.

The people who are afraid of AI are usually the ones who haven’t learned how to work with it yet.

Yes, I use AI. I can simply dictate a message, have AI turn it into text and translate it into English, and even post it for me. That gives me more time to work on something else — or simply have some free time.

I also use translation tools to communicate my thoughts more clearly in English. There is absolutely nothing wrong with using tools that make us more productive.

So please keep the hate to yourself if you don’t have any constructive criticism or actual suggestions.

So if you have no constructive criticism or suggestions regarding the library, just move on.

-8 points

To be precise: OPcache/JIT are both explicitly enabled in the benchmark's Docker image (opcache.enable_cli=1, opcache.jit=tracing) — this isn't a "without OPcache" number. And spatie/laravel-data's structure discovery is itself memoized in-process after the first call (CachedDataConfig), so reflection isn't re-run per hydration either. The gap comes from what runs after structure is known: laravel-data dispatches each ::from() through a ~7-step generic pipe pipeline (map/cast/validate/etc.) that re-walks the property list every call. OPcache/JIT speed up bytecode execution, not that per-call dispatch overhead. SDO compiles the whole thing into one specialized closure per class at build time, so there's no pipeline left to run.

1 points
yuriizeeOPRemoved · saved before deletion

Good question, and no plain-array scenario exists yet — that's a fair gap.

The baseline in every table is spatie/laravel-data on equivalent DTOs (same fields, same casts), not a no-op.

Against plain arrays there will always be a real penalty: you're paying for an object allocation, property assignment, and (if casts are declared) the cast logic itself — a bare $payload array skips all of that by definition.

What compiled metadata removes is the discovery cost (reflection/attribute parsing) that a naive DTO layer pays per-call, not the fundamental cost of "array vs. object."

I'll add an array-baseline scenario to the benchmark repo so that number is measured instead of guessed at.

-2 points

If very easy way - laravel

If more flexible, and professional project - Symfony

There are a lot of frameworks and libraries, but these are the tops.

0 points
yuriizeeRemoved · saved before deletion

What is the difference between bind(), singleton(), and scoped() in Laravel's Service Container, and which one is safe to use in long-lived processes such as Octane or queue workers?

In my experience, the answer to this question is often enough to tell whether someone is above middle Laravel developer.

The remaining questions are mostly about software architecture, database design, and the common patterns and practices used throughout the project.

1 points
yuriizeeRemoved · saved before deletion

I agree that ?? can easily be abused to suppress errors, but that’s a code quality issue, not a flaw with the feature itself.

For example, there's a totally valid fallback scenario between two interchangeable sources: $phone = $payload['mobile_phone'] ?? $payload['work_phone'] ?? null;.
Instead of building bulky checks with array_key_exists or isset for every key, you get a concise, highly readable expression.

So the tool itself is great — it’s all about using it for intentional fallbacks rather than masking a lack of input validation.

1 points

Good discussion either way — nice to see two libraries pressure-test each other in the open instead of just marketing copy. Good luck with dto, and thanks for engaging with this seriously.

1 points

u/dereuromark
Reposting context from the other thread since this seems like the canonical writeup people will land on: a few days ago I ended up benchmarking my own DTO library (std-out/simple-data-objects, compiled-closure hydration) against php-collective/dto under your post about it, and we compared real numbers back and forth (thread here:https://www.reddit.com/r/PHP/comments/1v2rz5v/).

Short version: hydration came out ~2–2.3x faster on my side with 4–5x less memory, serialization was ~5–10% in php-collective's favor on nested/collection payloads, and the bigger gap was on field transforms (compiled-in casts vs. transformValue($callable,$value) dispatch) — roughly 1M ops/sec vs 420K ops/sec.

Since this post is probably what most people searching "PHP DTO benchmarks" find, would you be open to adding simple-data-objects into the actual comparison table here alongside spatie/laravel-data and valinor? Happy to share the benchmark script so the numbers are reproducible on your end too.

1 points

Thanks!
That was genuinely the fun part to write up — each stage kills one specific cost: first replacing the ReflectionClass::newInstance()+setValue() loop with a specialized closure generated once per class, then getting eval() itself out of the hot path by persisting those compiled closures to a file cache that opcache serves pre-compiled on a warm worker. The single biggest jump, though, was the plain-property fast path: when a property has no cast, no nested DTO, no collection attached, the generated code is just $d['name'] ?? null — no dispatch through a generic value caster at all. That's most fields on a typical DTO, so it ended up mattering more than any of the fancier optimizations.

1 points

Quick follow-up — delivered this. v1.13.0 is out with the constructor-less bug fixed (plain property declarations now hydrate correctly, including readonly ones, toArray(), with(), and fromLazy()). While I was in there I also added support for classes that mix both styles — a constructor plus extra properties declared outside it — since it turned out to be the same underlying fix. Both are fully covered by tests (100% coverage, checked in CI) and don't touch the performance of regular constructor-based DTOs at all — verified that with a benchmark re-run before releasing.

The list<T>/virtual-properties points stand as documented limitations, not bugs — the #[DataCollection] attribute is still the way to do nested collections. Thanks again for the thorough pass, this was a genuinely useful bug report.

1 points

Thanks for actually digging into it, this is useful.

The list<T> docblock thing — yeah, nothing in the library reads docblocks at all, so that specific syntax was never going to work. The way to get a nested collection is #[DataCollection(ItemClass::class)] on a property typed TypedDataCollection, not a plain array. It's documented, just not where you'd look for it if you're thinking in generics-from-docblock terms, that's on me to make clearer.

The plain-property-no-constructor one — you're right, that's a real bug, not a misunderstanding. If a class has no constructor at all, my compiler ends up building new Class() with an empty arg list, so the whole input array just gets silently dropped instead of populating anything. Genuinely glad you found this one — I'm already working on a fix, should have a patched version out soon.

No virtual/computed properties, correct, that's just not a thing the library does. Not an oversight I'm defending, just hasn't been implemented.

The "Missing required field 'email'" one — I went and actually traced it instead of just trying to repro. Ran your exact SignupData1 class with email = 'default' and it hydrates fine, no exception. But more than that: I checked the compiler itself, and the throw for a missing field only gets emitted into the generated code when the parameter has no default — it's decided at compile time, not runtime, so for a parameter that has a default, that throw branch literally isn't in the function that runs. It's not "works on my machine," it structurally can't produce that error for this exact class shape as the compiler stands today. My best guess is a stale cache from testing an earlier version of the class before you added the default — there's no invalidation on source changes right now if you'd set a persisted cache dir, which honestly might be worth its own fix. Could be a version mismatch too. If you've still got the setup, I'd genuinely like to see it.

Appreciate you actually running it through its paces instead of just reading the README — this is exactly the kind of feedback that makes it better. If anyone wants to jump in, poke more holes, or send a PR, repo's at github.com/std-out/simple-data-objects, always happy for more eyes on it.

1 points

I actually went and benchmarked it instead of leaving it at "prove me wrong."

I made sure both DTOs had identical schemas (I initially found two mismatches myself: one field was required instead of optional, and one nested collection field was missing. Fixed both, reran everything, and the numbers didn't really change). I also tested collection sizes from 20 all the way up to 20,000 items to make sure this wasn't just a small-sample effect.

For hydration, mine is consistently around 2–2.3x faster while using roughly 4–5x less memory per object. That stayed pretty much the same regardless of collection size.

Serialization is a different story though. Your generated toArrayFast() is basically just a flat array literal, so it's about as optimal as PHP gets. In my tests you actually came out 5–10% ahead on nested/collection payloads. Fair enough.

The biggest difference shows up once you introduce transforms, even simple ones like a boolean cast or trim(strtolower(...)). I tested four trivial field transforms and got roughly 1M ops/sec on my side versus about 420K ops/sec on yours.

From what I could see, that's mostly because transformed fields still go through transformValue($callable, $value) during hydration. That makes sense for a generic callable-based design, but it does add overhead. My approach is different: those casts are compiled directly into the generated hydration code, so there isn't an extra function call for every transformed field.

One thing I do think is worth pointing out is that our approaches are simply different.

PhpCollective generates PHP classes whenever the DTO schema changes. Those generated files are meant to be regenerated, so they're not really something you'd normally edit by hand. My library keeps the DTO classes themselves small and readable, while all the optimized hydration logic is compiled into cache. That means the code you actually write stays clean, your PRs only contain the DTO changes you made, and the generated optimization layer stays out of the repository. It's a different trade-off, not necessarily a better one.

For anyone curious, here's the setup:

  • PHP 8.5.4 CLI
  • JIT disabled
  • 2,000 warmup iterations
  • 20,000 timed iterations per scenario
  • PhpCollective DTO 0.1.19

If anyone wants to reproduce the results, I'm happy to share the benchmark script. If there's something I overlooked, I'd genuinely like to know.

And just to be clear, I think PhpCollective is a really good library. It solves the same problem with a different philosophy. My focus has been squeezing as much performance as possible out of hydration while keeping the DTO classes themselves minimal. PhpCollective takes a different approach, and I think it's a solid solution as well.

1 points

Run any AI coding agent in the project root—Claude Code, Gemini CLI, Codex, or any other.

Start by preparing a project specification using Markdown files (md). Document what the project is, its architecture, coding conventions, testing strategy, code style, and any other important project-specific rules.

That alone is usually enough to make a significant difference in how well the AI understands your project's context.

From there, you can start creating custom skills or workflows. For example, when implementing a new feature, the agent could automatically scaffold the entire CRUD structure, including controllers, models, migrations, services, factories, tests, and any other project-specific boilerplate.

2 points

Assuming you mean Marco Pivetta's GeneratedHydrator — similar philosophy (codegen instead of runtime reflection), different scope: GeneratedHydrator hydrates plain objects via generated proxies, this compiles per-class factory closures specifically for DTOs with casting/validation/lazy-ghost support baked in. Not a strict "better," just built for a narrower job. Haven't benchmarked directly against it, honestly — good suggestion, might do that.

0 points

End of this list.

Back to top

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.