Skip to content

Commit cbca3dd

Browse files
author
DKravtsov
committed
Updated docs and configuration.
1 parent b5450b7 commit cbca3dd

27 files changed

+115
-102
lines changed

.idea/externalDependencies.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php-test-framework.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/development.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,48 @@ This document contains basic information and recommendation for development.
1616
* Use strict_types, type hinting and return type hinting.
1717
* Use PHPStorm IDE as currently it is most powerful IDE for PHP development on today's market.
1818

19-
Within this application the base workflow is following:
19+
For this application the base workflow is following:
2020

2121
`Controller/Command/EventSubscriber/MessageHandler(Transport layer) <--> Resource/Service(Application layer) <--> Repository/Service(Infrastructure layer) <--> Entity/Message/Service(Domain layer)`
2222

2323
#### Exceptions
24-
* All Exceptions that should terminate the current request (and return an error message to the user) should be handled
25-
using Symfony [best practice](https://symfony.com/doc/current/controller/error_pages.html#use-kernel-exception-event).
26-
* All Exceptions that should be handled in the controller, or just logged for debugging, should be wrapped in a
27-
try catch block (catchable Exceptions).
24+
* All Exceptions that should terminate the current request (and return an error message to the user) should be handled using Symfony [best practice](https://symfony.com/doc/current/controller/error_pages.html#use-kernel-exception-event).
25+
* All Exceptions that should be handled in the controller, or just logged for debugging, should be wrapped in a try catch block (catchable Exceptions).
2826
* Use custom Exceptions for all catchable scenarios, and try to use standard Exceptions for fatal Exceptions.
2927
* Use custom Exceptions to log.
3028

3129
#### Entities
32-
Entities should only be data-persistence layers, i.e. defines relationships, attributes, helper methods
33-
but does not fetch collections of data. Entities are located on the Domain layer (according to DDD approach) and shouldn't
34-
know anything about other layers (Application/Infrastructure) or framework. In this application we made some "exception"
35-
for such components like Doctrine/Swagger/Serializer/Validator (for the first time) and you can find such
36-
dependencies inside Entities.
37-
38-
Within this application we are using uuid v1 for the primary key inside Entities. Also we have id field as
39-
binary type ([details](https://uuid.ramsey.dev/en/stable/database.html#using-as-a-primary-key)). If you need to convert
40-
id into binary ordered time or from bin ordered time into a string inside query, please use MySql 8 internal functions [UUID_TO_BIN](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin) and [BIN_TO_UUID](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_bin-to-uuid).
30+
Entities should only be data-persistence layers, i.e. defines relationships, attributes, helper methods but does not fetch collections of data.
31+
Entities are located on the Domain layer (according to DDD approach) and shouldn't know anything about other layers (Application/Infrastructure) or framework.
32+
In this application we made some "exception" for such components like Doctrine/Swagger/Serializer/Validator (for the first time) and you can find such dependencies inside Entities.
33+
34+
Inside this application we are using uuid v1 for the primary key inside Entities. Also we have id field as binary type ([details](https://uuid.ramsey.dev/en/stable/database.html#using-as-a-primary-key)).
35+
If you need to convert id into binary ordered time or from bin ordered time into a string inside query, please use MySql 8 internal functions [UUID_TO_BIN](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid-to-bin) and [BIN_TO_UUID](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_bin-to-uuid).
4136
For instance `... WHERE id = UUID_TO_BIN(:id, 1)`, or when you need to convert uuid binary ordered time into string representative `... WHERE BIN_TO_UUID(id, 1) = :id`.
42-
The second argument determines if the byte order should be swapped, therefore when using uuid_binary you should pass 0 and when using uuid_binary_ordered_time you should pass 1.
37+
The second argument determines if the byte order should be swapped. Therefore, when using uuid_binary, you should pass 0. When using uuid_binary_ordered_time you should pass 1.
4338

4439
#### Repositories
45-
Repositories need to be responsible for parameter handling and query builder callbacks/joins. Should be located on
46-
infrastructure layer. Parameter handling can help with generic REST queries.
40+
Repositories need to be responsible for parameter handling and query builder callbacks/joins. Should be located on infrastructure layer. Parameter handling can help with generic REST queries.
4741

4842
#### Resources
49-
Resource services are services between your controller/command and repository. Should be located on application layer.
50-
Within this service it is possible to control how to `mutate` repository data for application needs.
43+
Resource services are services between controller/command and repository. Should be located on application layer.
44+
Inside this service it is possible to control how to `mutate` repository data for application needs.
5145
Resource services are basically the application foundation and it can control your request and response as you like.
52-
We have provided 2 examples how to build resource services: 1)resource with all-in-one actions (create/update/delete/etc, see example src/ApiKey/Application/Resource/ApiKeyResource.php)
46+
47+
We have provided 2 examples how to build resource services:
48+
49+
1)resource with all-in-one actions (create/update/delete/etc, see example src/ApiKey/Application/Resource/ApiKeyResource.php)
50+
5351
2)resource with single responsibility (f.e. count, see example src/ApiKey/Application/Resource/ApiKeyCountResource.php).
5452

5553
#### Controllers
56-
Should be located on Transport layer. Keep controllers clean of application logic. They should ideally just inject
54+
Should be located on the Transport layer. Keep controllers clean of application logic. They should ideally just inject
5755
resources/services - either through the constructor (if used more than once) or in the controller method itself.
58-
We have provided 2 examples how to build controllers: 1)controller with all-in-one actions (create/update/delete/etc, see example src/ApiKey/Transport/Controller/Api/v1/ApiKey/ApiKeyController.php)
56+
57+
We have provided 2 examples how to build controllers:
58+
59+
1)controller with all-in-one actions (create/update/delete/etc, see example src/ApiKey/Transport/Controller/Api/v1/ApiKey/ApiKeyController.php)
60+
5961
2)controller with single responsibility (f.e. count, see example src/ApiKey/Transport/Controller/Api/v2/ApiKey/ApiKeyCountController.php)
6062

6163
#### Events
@@ -70,7 +72,7 @@ Isolate 3rd party dependencies into Service classes for simple refactoring/exten
7072

7173
## PHP code quality
7274
You can control code quality of your PHP project using already integrated code quality tools. Before creating merge request you can run on your local PC code quality tools and get the report with issues that you can fix.
73-
Also code quality tools integrated inside CI environment and after creating merge request you can check if you have some issues inside your code. Please find the list of code quality tools that we recommend to use while PHP backend development.
75+
Also code quality tools integrated inside CI environment and, after creating merge request, you can check if you have some issues inside your code. Please find the list of code quality tools that we recommend to use for PHP backend development.
7476

7577
### PHP coding standard
7678
This tool is an essential development tool that ensures your code remains coding standard.
@@ -80,7 +82,7 @@ PHP coding standard is available for dev/test environment using next local shell
8082
make ecs
8183
```
8284

83-
If you want to fix all possible issues in auto mode(some issues can be fixed only manually) just use next local shell command:
85+
If you want to fix all possible issues in auto mode(some issues can be fixed only manually), just use next local shell command:
8486
```bash
8587
make ecs-fix
8688
```
@@ -93,8 +95,7 @@ PHP Code Sniffer is available for dev/test environment using next local shell co
9395
make phpcs
9496
```
9597

96-
If you are using [PhpStorm](https://www.jetbrains.com/phpstorm/) you can configure PHP Code Sniffer using recommendation
97-
[here](https://www.jetbrains.com/help/phpstorm/using-php-code-sniffer.html).
98+
If you are using [PhpStorm](https://www.jetbrains.com/phpstorm/) you can configure PHP Code Sniffer using recommendation [here](https://www.jetbrains.com/help/phpstorm/using-php-code-sniffer.html).
9899

99100
### PHPStan static analysis tool
100101
PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code.
@@ -135,18 +136,18 @@ make phpcpd-html-report
135136
```
136137

137138
### Composer tools
138-
To normalize or validate your composer.json you can use next local shell commands:
139+
To normalize or validate your composer.json, you can use next local shell commands:
139140
```bash
140141
make composer-normalize
141142
make composer-validate
142143
```
143144

144-
If you need to find unused packages by scanning your code you can use next local shell commands:
145+
If you need to find unused packages by scanning your code, you can use next local shell commands:
145146
```bash
146147
make composer-unused
147148
```
148149

149-
In order to check the defined dependencies against your code you can use next local shell commands:
150+
In order to check the defined dependencies against your code, you can use next local shell commands:
150151
```bash
151152
make composer-require-checker
152153
```
@@ -157,7 +158,7 @@ Use next local shell command in order to run it:
157158
```bash
158159
make phpmetrics
159160
```
160-
Note: You need run tests before this local shell command.
161+
Note: You need to run tests before this local shell command.
161162

162163
After execution above local shell command please open `reports/phpmetrics/index.html` with your browser.
163164

@@ -203,7 +204,7 @@ Please use next workflow for migrations:
203204

204205
Above commands you can run in symfony container shell using next: `./bin/console doctrine:migrations:<command>`.
205206

206-
Using above workflow allow you make database changes on your application.
207+
Using above workflow allows you make database changes on your application.
207208
Also you do not need to make any migrations files by hand (Doctrine will handle it).
208209
Please always check generated migration files to make sure that those doesn't contain anything that you really don't want.
209210

docs/images/phpstorm_01.png

-27.1 KB
Loading

docs/images/phpstorm_02.png

12.6 KB
Loading

docs/images/phpstorm_03.png

-18 KB
Loading

docs/images/phpstorm_04.png

10.6 KB
Loading

docs/images/phpstorm_05.png

6.37 KB
Loading

docs/images/phpstorm_06.png

-7.52 KB
Loading
7.53 KB
Loading
-1.33 KB
Loading
8.63 KB
Loading
-690 Bytes
Loading

docs/images/phpstorm_phpmd_1.png

8.18 KB
Loading

docs/images/phpstorm_phpmd_2.png

-827 Bytes
Loading

docs/images/phpstorm_phpstan_1.png

7.38 KB
Loading

docs/images/phpstorm_phpstan_2.png

-990 Bytes
Loading

docs/images/xdebug_01.png

53.5 KB
Loading

docs/images/xdebug_02.png

74.8 KB
Loading

docs/messenger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Messenger
2-
This document describing how you can use [symfony/messenger](https://symfony.com/doc/current/messenger.html) bundle inside this environment.
2+
This document describing how you can use [symfony/messenger](https://symfony.com/doc/current/messenger.html) bundle.
33

44
## Basics
55

0 commit comments

Comments
 (0)