You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/v6/tutorials/create-book-module.md
+45-58Lines changed: 45 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,28 +18,26 @@ The below files structure is what we will have at the end of this tutorial and i
18
18
│ │ ├── GetBookHandler.php
19
19
│ │ └── PostBookHandler.php
20
20
│ ├── InputFilter/
21
+
│ │ ├── Input/
22
+
│ │ │ ├── AuthorInput.php
23
+
│ │ │ ├── NameInput.php
24
+
│ │ │ └── ReleaseDateInput.php
21
25
│ │ └── CreateBookInputFilter.php
22
26
│ ├── Service/
23
27
│ │ ├── BookService.php
24
28
│ │ └── BookServiceInterface.php
25
29
│ ├── ConfigProvider.php
26
30
│ └── RoutesDelegator.php
27
-
├── Core/
28
-
│ └── src/
29
-
│ └── Book/
30
-
│ └── src/
31
-
│ ├──Entity/
32
-
│ │ └──Book.php
33
-
│ ├──Repository/
34
-
│ │ └──BookRepository.php
35
-
│ └── ConfigProvider.php
36
-
└── App/
37
-
└──src/
38
-
└── InputFilter/
39
-
└── Input/
40
-
├── AuthorInput.php
41
-
├── NameInput.php
42
-
└── ReleaseDateInput.php
31
+
└── Core/
32
+
└── src/
33
+
└── Book/
34
+
└── src/
35
+
├──Entity/
36
+
│ └──Book.php
37
+
├──Repository/
38
+
│ └──BookRepository.php
39
+
└── ConfigProvider.php
40
+
43
41
```
44
42
45
43
*`src/Book/src/Collection/BookCollection.php` - a collection refers to a container for a group of related objects, typically used to manage sets of related entities fetched from a database
@@ -52,7 +50,7 @@ The below files structure is what we will have at the end of this tutorial and i
52
50
*`src/Book/src/ConfigProvider.php` - is a class that provides configuration for various aspects of the framework or application
53
51
*`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
54
52
*`src/Book/src/InputFilter/CreateBookInputFilter.php` - input filters and validators
55
-
*`src/Core/src/App/src/InputFilter/Input/*` - input filters and validator configurations
53
+
*`src/Book/src/InputFilter/Input/*` - input filters and validator configurations
56
54
57
55
## Creating and configuring the module
58
56
@@ -180,57 +178,46 @@ In `src/Core/src/Book/src` we will create 1 PHP file: `ConfigProvider.php`. This
180
178
181
179
declare(strict_types=1);
182
180
183
-
namespace Api\Book;
181
+
namespace Core\Book;
184
182
185
-
use Api\App\ConfigProvider as AppConfigProvider;
186
-
use Api\App\Factory\HandlerDelegatorFactory;
187
-
use Api\Book\Collection\BookCollection;
188
-
use Api\Book\Handler\GetBookCollectionHandler;
189
-
use Api\Book\Handler\GetBookHandler;
190
-
use Api\Book\Handler\PostBookHandler;
191
-
use Api\Book\Service\BookService;
192
-
use Api\Book\Service\BookServiceInterface;
193
-
use Core\Book\Entity\Book;
194
-
use Dot\DependencyInjection\Factory\AttributedServiceFactory;
195
-
use Mezzio\Application;
196
-
use Mezzio\Hal\Metadata\MetadataMap;
183
+
use Core\Book\Repository\BookRepository;
184
+
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
185
+
use Dot\DependencyInjection\Factory\AttributedRepositoryFactory;
@@ -468,14 +455,14 @@ class BookService implements BookServiceInterface
468
455
469
456
When creating or updating a book, we will need some validators, so we will create input filters that will be used to validate the data received in the request
470
457
471
-
*`src/App/src/InputFilter/Input/AuthorInput.php`
458
+
*`src/Book/src/InputFilter/Input/AuthorInput.php`
472
459
473
460
```php
474
461
<?php
475
462
476
463
declare(strict_types=1);
477
464
478
-
namespace Api\App\InputFilter\Input;
465
+
namespace Api\Book\InputFilter\Input;
479
466
480
467
use Core\App\Message;
481
468
use Laminas\Filter\StringTrim;
@@ -505,14 +492,14 @@ class AuthorInput extends Input
505
492
}
506
493
```
507
494
508
-
*`src/App/src/InputFilter/Input/NameInput.php`
495
+
*`src/Book/src/InputFilter/Input/NameInput.php`
509
496
510
497
```php
511
498
<?php
512
499
513
500
declare(strict_types=1);
514
501
515
-
namespace Api\App\InputFilter\Input;
502
+
namespace Api\Book\InputFilter\Input;
516
503
517
504
use Core\App\Message;
518
505
use Laminas\Filter\StringTrim;
@@ -542,14 +529,14 @@ class NameInput extends Input
0 commit comments