Answer the question
In order to leave comments, you need to log in
What should be the application architecture without ActiveRecord in Yii2?
Here we quickly created a project on AR (ActeveRecord) requests through it, recording and updating. To start a new project, I think this is quite normal, despite the fact that the project may not take off.
But the project lives on, AR models swell with logic. The database is growing, along with the volume of processed information. And you already need to think about how to take the logic out of AR (behaviors, AfterSave, BeforeSave) in the first place, so that it can be applied with batchInsert and batchUpdate.
A small digression, about the logic, examples:
Answer the question
In order to leave comments, you need to log in
Application business logic in components, implementation in controllers, and models should be as thin as possible. In models, the only logic is behavior in the form of timestamp, slug,...
Business logic is better to take out in services. Each service should deal with some of its tasks. For example, one works with orders, the other sends notifications. How the service will be general or vice versa specific is up to you. Services can be linked together by inheritance, aggregation, composition (listed in order from strong to weak). In order not to rack your brains, you can use ready-made design patterns.
This is where the Observer design pattern comes into play. An event is created for a status change, which is received by all subscribers.
Here I would think about using the Decorator pattern
Yes, there are already standard solutions, you just need to study and try in practice for your tasks.
I don’t know about projects, you can probably just search on github for what you are interested in. The use of patterns with examples is well described here https://refactoring.guru/en/design-patterns/catalog
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question