Comparing
#86 with
#89
Content
[...]
Why? Because these are usually only modified by developers and creating migrations because of every small change is tedious.
I recommend storing them in PHP files. In case of RBAC the only thing you want to have in DB is the assignment of users to roles so they can be changed via WEB UI.
## DDD (Domain-Driven Design)
If this is an incomprehensible topic to you, you may be too focused on DB like I was. Let's drop it! Let's forget about DB and ActiveRecord - it is one of the best ways to understand DDD. Without a database, you naturally design your objects around your business rather than database schemas. Then you will easily understand and implement Aggregates, Repositories, Value Objects and other basic stones of DDD.
For example: Value Object is a great tool for auto-validation of small data (email addresses). If you then pass this object as an argument, the recipient can be sure you provided a valid email address. Etc.
So let's try to implement a small in-memory-information-system with just vanilla PHP. DB is an additional and optional layer.
## Vectical slices
It is just a name for a different folder structure. We all know MVC from Yii2 - main folders are Controllers, Models, Views, Migrations and Services.
Note: Services should contain the logic that is usually coded in Controllers, but Controllers should technically only process the request and the Service should do the logic. Controllers are not easily testable (they require the HTTP request), Services are.
So instead of folders:
- /src/Controllers
- /src/Models
- /src/Views
- /src/Migrations
- /src/Services
You bundle all what is related (for example) to User into one folder. Plus: Instead of "Actions" we use name "UseCase":
- /src/User/UseCase/Create/Action.php + view.php
- /src/User/UseCase/Update/Action.php + view.php
- /src/User/Migration/M123.php
- ...
You can say that Vertical slices are MVC rotated by 90° (or flipped inside out)
If anything is shared, you can place it to folder /src/Shared. You can do whatever you want as long as it is a clean and nice solution.
## ===== Yii3 - How to start ======
Yii3 offers more basic applications: Web, Console, API. I will be using the WEB application:
- https://github.com/yiisoft/app
- Other apps are linked on the page[...]