-
Notifications
You must be signed in to change notification settings - Fork 2
Issue #110: update book tutorial #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: horea <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be continued...
Signed-off-by: horea <[email protected]>
Signed-off-by: horea <[email protected]>
Signed-off-by: horea <[email protected]>
Signed-off-by: horea <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
In
ReleaseDateInput
, replace:
'message' => sprintf(Message::INVALID_VALUE, 'releaseDate'),
with:
'message' => Message::INVALID_VALUE,
and removeuse function sprintf;
. -
The migrations diff command is outdated, replace it with:
php ./vendor/bin/doctrine-migrations diff
- The path mentioned in this sentence has changed in
6.0
:
This will check for differences between your entities and database structure and create migration files if necessary, in
data/doctrine/migrations
.
Version 6.0
stores migrations in the Core module under the following path:
src/Core/src/App/src/Migration
- The migrations run command should also be updated:
php ./vendor/bin/doctrine-migrations migrate
-
Rename across the document
GetBookHandler
toGetBookResourceHandler
-
Rename across the document
PostBookHandler
toPostBookResourceHandler
so that they follow our naming convention.
Signed-off-by: horea <[email protected]>
Signed-off-by: horea <[email protected]>
Signed-off-by: horea <[email protected]>
|
||
To execute the migrations run: | ||
|
||
```shell | ||
vendor/bin/doctrine-migrations migrate | ||
php ./vendor/bin/doctrine-migrations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php ./vendor/bin/doctrine-migrations | |
php ./vendor/bin/doctrine-migrations migrate |
]; | ||
} | ||
$routeCollector->post('/book', PostBookHandler::class, 'book::create-book'); | ||
$routeCollector->get('/book/' . $uuid, GetBookHandler::class, 'book::view-book'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$routeCollector->get('/book/' . $uuid, GetBookHandler::class, 'book::view-book'); | |
$routeCollector->get('/book/' . $uuid, GetBookResourceHandler::class, 'book::view-book'); |
Because:
Rename across the document
GetBookHandler
toGetBookResourceHandler
], | ||
]; | ||
} | ||
$routeCollector->post('/book', PostBookHandler::class, 'book::create-book'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$routeCollector->post('/book', PostBookHandler::class, 'book::create-book'); | |
$routeCollector->post('/book', PostBookResourceHandler::class, 'book::create-book'); |
Because:
Rename across the document
PostBookHandler
toPostBookResourceHandler
│ └── src/ | ||
│ ├── Collection/ | ||
│ │ └── BookCollection.php | ||
│ ├── Entity/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove node - the Book
entity is in the Core
module.
* `src/Book/src/InputFilter/CreateBookInputFilter.php` – input filters and validators | ||
* `src/Book/src/InputFilter/Input/*` – input filters and validator configurations | ||
* `src/Book/src/RoutesDelegator.php` – a routes delegator is a delegator factory responsible for configuring routing middleware based on routing configuration provided by the application | ||
* `src/Book/src/Service/BookService.php` – is a class or component responsible for performing a specific task or providing functionality to other parts of the application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `src/Book/src/Service/BookService.php` – is a class or component responsible for performing a specific task or providing functionality to other parts of the application | |
* `src/Book/src/Service/BookService.php` – is a class or component responsible for performing a specific task or providing functionality to other parts of the application | |
* `src/Book/src/Service/BookServiceInterface.php` – interface that reflects the publicly available methods in `BookService` |
> Make sure you read and understand the rbac documentation. | ||
|
||
It's time to update the `ConfigProvider` with all the necessary configuration needed, so the above files to work properly like dependency injection, aliases, doctrine mapping and so on. | ||
After we have the handler, we need to register some routes in the `RoutesDelegator` using our new grouping method, the same we created when we registered the module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After we have the handler, we need to register some routes in the `RoutesDelegator` using our new grouping method, the same we created when we registered the module. | |
After we have the handler, we need to register some routes in the `RoutesDelegator`, the same we created when we registered the module. |
We abandoned route groups for this tutorial.
|
||
In `src/Book/src` we will create 2 php files: `RoutesDelegator.php` and `ConfigProvider.php`. This files will be updated later with all needed configuration. | ||
In `src/Book/src` we will create 2 PHP files: `RoutesDelegator.php` and `ConfigProvider.php`. These files contain the necessary configurations. | ||
|
||
* `src/Book/src/RoutesDelegator.php` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is duplicate - you are creating the RoutesDelegator
towards the end of the tutorial.
Let's keep only that one!
* `src/Book/src/Service/BookService.php` – is a class or component responsible for performing a specific task or providing functionality to other parts of the application | ||
* `src/Core/src/Book/src/ConfigProvider.php` – is a class that provides configuration for Doctrine ORM | ||
* `src/Core/src/Book/src/Entity/Book.php` – an entity refers to a PHP class that represents a persistent object or data structure | ||
* `src/Core/src/Book/src/Repository/BookRepository.php` – a repository is a class responsible for querying and retrieving entities from the database | ||
|
||
## Creating and configuring the module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section could be a bit confusing for devs.
You instruct them to create a ConfigProvider
with classes which don't exist yet - better leave it for when all the classes have been created.
We should keep here only the instructions for creating the directory structure and move the creation of the two ConfigProvider
s and the RouteDelegator
to the end of the File creation and contents
section.
], | ||
], | ||
]; | ||
} | ||
} | ||
``` | ||
|
||
### Registering the module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section should also be moved further down to the point where the ConfigProvider
has already been created.
|
||
To keep things simple in this tutorial our book will have 3 properties: `name`, `author` and `release date`. | ||
To keep things simple in this tutorial, our book will have 3 properties: `name`, `author` and `release date`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep things simple in this tutorial, our book will have 3 properties: `name`, `author` and `release date`. | |
To keep things simple in this tutorial, our book will have 3 properties: `name`, `author` and `releaseDate`. |
@@ -460,29 +555,29 @@ class ReleaseDateInput extends Input | |||
|
|||
$this->getValidatorChain() | |||
->attachByName(Date::class, [ | |||
'message' => sprintf(Message::INVALID_VALUE, 'releaseDate'), | |||
'message' => Message::INVALID_VALUE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'message' => Message::INVALID_VALUE, | |
'message' => Message::invalidValue('releaseDate'), |
Signed-off-by: horea <[email protected]>
No description provided.