Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Randy_Johnson's avatar

Event-Driven Architecture, do I need it?

So am progressing with the website with the help of AI, and its telling me I should implement event driven architecture for my stock/ items page.

Reading through it, it looks pretty complicated. Here is a snippet of code.

app(AdjustInventoryStockAction::class)->execute(
    item: $item,
    newQuantity: $validated['quantity'],
    type: 'adjustment',
    reason: 'Manual inventory update',
    performedBy: Auth::id(),
);

Should I bite the nail and continue down this road since it will eventually lead to a better product, or is AI leading me on a wild goose chance?

0 likes
5 replies
Tray2's avatar

I think you should learn how to code, and then use AI as a tool, and not as a developer.

3 likes
imrandevbd's avatar

Honestly, ignore the AI on this one. What you’ve written is a solid, clean Action class. It’s readable, it handles the transaction properly, and it gets the job done.

EDA is fantastic for decoupling, but it’s absolute overkill for a simple stock adjustment. You only really need to go down that road if a stock change needs to trigger a bunch of unrelated side effects like hitting a third-party API, sending emails, or clearing remote caches and you don't want to bloat your main logic.

2 likes
martinbean's avatar

Should I bite the nail and continue down this road since it will eventually lead to a better product

@randy_johnson “Better” according to who…?

Event-driven architecture is like any other paradigm: it can be implemented well and it can be implemented poorly. Just implementing an event-driven architecture won’t automatically and inherently make the end result “better”.

If this is an inventory system then all you need to do is record adjustments in a table. Insert a row each time you take stock, and each time stock leaves (i.e. is sold).

1 like
vincent15000's avatar

I regularly use AI.

When I started using AI, I was impressed about the results, but there was frequently errors, too frequently. I lost time because of using AI.

Now I'm using AI only to save time for writing code I already know how write it, but much faster to write by the AI : I say to AI exactly what I want and there are less errors, I just have to correct some mistakes.

If you don't know what you need, the AI is not the best approach to code.

You must know what you need, then you can explain the AI exactly what you need, and the AI executes.

According to me you don't need EDA for your example.

I often say to me that I should always code as easy as possible (KISS principle).

Please or to participate in this conversation.