DotKernel 3 follows the rules described in the PHP-FIG PSR-2 document.
The entity is the representation of an object.
The following are entities
- a
post - a
document - a
userrelation
Classes that represent entities are following the following structure:
- Must start with the entity name
- Must end with the word
Entity - Must contain no other words unless they define a relation
Examples of named entities
PostEntity- represents a blog postDocumentEntity- represents a documentDocuentUserEntity- represents a document with a user relation
Note: our recommendation is to name the class attributes (object properties) the same as the column names in persistent storage (database)
The collection is the representation of a list of objects.
Programatically speaking: a collection is an iterable set of entities.
The following are collections
- a list of
posts - a list of
documents - a list of
usersin relation to the document
Classes that represent entities are following the following structure:
- Must start with the entity name,
- Must end with the word
Collection
Examples of named collections
PostCollection- represents a blog post listDocumentCollection- represents a document listDocumentUserCollection- represents a list of users
Middleware simply calls the code
The "Resources" or the "Middleware" should contain only base operation.
For instance, queries like SELECT- FROM (...) won't be written directly in the middleware
Code like $db->select()->from() will also be avoided when writing the middleware.
In PSR-7 applications Interfaces will be highly used. These interfaces only contain the basic / common behaviour.
- POST
- GET
- PUT
- PATCH
- DELETE
Your services/modules will have interfaces to make them compatible with any PSR-7 Middleware application-stack.