Skip to content

Commit

Permalink
Merge pull request #247 from dotkernel/docs-updates
Browse files Browse the repository at this point in the history
Documentation updates
  • Loading branch information
arhimede authored May 14, 2024
2 parents 04588bb + 41a8b7d commit 5095ff9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 48 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Based on Enrico Zimuel's [Zend Expressive API - Skeleton example](https://github
[![GitHub license](https://img.shields.io/github/license/dotkernel/api)](https://github.com/dotkernel/api/blob/4.0/LICENSE.md)

[![Build Static](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/api/actions/workflows/continuous-integration.yml)
[![Build Static](https://github.com/dotkernel/api/actions/workflows/run-tests.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/api/actions/workflows/run-tests.yml)
[![codecov](https://codecov.io/gh/dotkernel/api/graph/badge.svg?token=53FN78G5CK)](https://codecov.io/gh/dotkernel/api)
[![Qodana](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml/badge.svg)](https://github.com/dotkernel/api/actions/workflows/qodana_code_quality.yml)

Expand Down
2 changes: 1 addition & 1 deletion docs/book/v4/introduction/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Sending a GET request to the [home page](http://0.0.0.0:8080/) should output the
## Running tests

The project has 2 types of tests : functional and unit tests, you can run both types at the same type by executing this command:
The project has 2 types of tests: functional and unit tests, you can run both types at the same type by executing this command:

```shell
php vendor/bin/phpunit
Expand Down
37 changes: 18 additions & 19 deletions docs/book/v4/introduction/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,27 @@ Here is a list of the core components:

* Middleware Microframework (mezzio/mezzio)
* Error Handler (dotkernel/dot-errorhandler)
* Problem Details (mezzio-problem-details)
* CORS (mezzio-cors)
* Problem Details (mezzio/mezzio-problem-details)
* CORS (mezzio/mezzio-cors)
* Routing (mezzio/mezzio-fastroute)
* Authentication (mezzio-authentication)
* Authorization (mezzio-authorization)
* Authentication (mezzio/mezzio-authentication)
* Authorization (mezzio/mezzio-authorization)
* Config Aggregator (laminas/laminas-config-aggregator)
* Container (roave/psr-container-doctrine)
* Implicit Head, Options and Method Not Allowed
* Annotations (dotkernel/dot-annotated-services)
* Input Filter (laminas/laminas-inputfilter)
* Doctrine
* Hydrator (laminas/laminas-hydrator)
* Doctrine 2 ORM (doctrine/orm)
* Serializer/Deserializer (laminas/laminas-hydrator)
* Paginator (laminas/laminas-paginator)
* HAL (mezzio-hal)
* HAL (mezzio/mezzio-hal)
* CLI (dotkernel/dot-cli)
* TwigRenderer (mezzio/mezzio-twigrenderer)
* Fixtures (dotkernel/dot-data-fixtures)
* UUID (ramsey/uuid-doctrine)

## Doctrine 2 ORM

For the persistence in a relational database management system we chose Doctrine ORM (object-relational mapper) .
For the persistence in a relational database management system we chose Doctrine ORM (object-relational mapper).

The benefit of Doctrine for the programmer is the ability to focus on the object-oriented business logic and worry about persistence only as a secondary priority.

Expand All @@ -40,15 +39,15 @@ Our documentation is Postman based. We use the following files in which we store

## Hypertext Application Language

For our API payloads ( a value object for describing the API resource, its relational links and any embedded/child resources related to it ) we chose mezzio-hal.
For our API payloads (a value object for describing the API resource, its relational links and any embedded/child resources related to it) we chose mezzio-hal.

## CORS

By using `MezzioCorsMiddlewareCorsMiddleware`, the CORS preflight will be recognized and the middleware will start to detect the proper CORS configuration. The Router is used to detect every allowed request method by executing a route match with all possible request methods. Therefore, for every preflight request, there is at least one Router request.

## OAuth 2
## OAuth 2.0

OAuth 2 is an authorization framework that enables applications to obtain limited access to user accounts on your DotKernel API. We are using mezzio/mezzio-authentication-oauth2 which provides OAuth2 authentication for Mezzio and PSR-7/PSR-15 applications by using league/oauth2-server package.
OAuth 2.0 is an authorization framework that enables applications to obtain limited access to user accounts on your DotKernel API. We are using mezzio/mezzio-authentication-oauth2 which provides OAuth 2.0 authentication for Mezzio and PSR-7/PSR-15 applications by using league/oauth2-server package.

## Email

Expand All @@ -66,7 +65,7 @@ You can further customize your api within the autoload directory where each conf

## Routing

Each Module has a `RoutesDelegator.php` file for managing existing routes inside that specific module. It also allows a quick way of adding new routes by providing the route path, Middlewares that the route will use and the route name.
Each module has a `RoutesDelegator.php` file for managing existing routes inside that specific module. It also allows a quick way of adding new routes by providing the route path, Middlewares that the route will use and the route name.

You can allocate permissions per route name in order to restrict access for a user role to a specific route in `config/autoload/authorization.global.php`.

Expand All @@ -76,17 +75,17 @@ For registering new commands first make sure your command class extends `Symfony

## File locker

Here you will also find our brand-new file locker configuration, so you can easily turn it on or off ( by default: `'enabled' => true` )
Here you will also find our brand-new file locker configuration, so you can easily turn it on or off (by default: `'enabled' => true`).

Note: The File Locker System will create a `command-{command-default-name}.lock` file which will not let another instance of the same command to run until the previous one has finished.

## PSR Standards

* PSR-3: Logger Interface – the application uses `LoggerInterface` for error logging
* PSR-4: Autoloader – the application locates classes using an autoloader
* PSR-7: HTTP message interfaces – the handlers return `ResponseInterface`
* PSR-11: Container interface – the application is container-based
* PSR-15: HTTP Server Request Handlers – the handlers implement `RequestHandlerInterface`
* [PSR-3](https://www.php-fig.org/psr/psr-3/): Logger Interface – the application uses `LoggerInterface` for error logging
* [PSR-4](https://www.php-fig.org/psr/psr-4): Autoloader – the application locates classes using an autoloader
* [PSR-7](https://www.php-fig.org/psr/psr-7): HTTP message interfaces – the handlers return `ResponseInterface`
* [PSR-11](https://www.php-fig.org/psr/psr-11): Container interface – the application is container-based
* [PSR-15](https://www.php-fig.org/psr/psr-15): HTTP Server Request Handlers – the handlers implement `RequestHandlerInterface`

## Tests

Expand Down
55 changes: 30 additions & 25 deletions docs/book/v4/tutorials/create-book-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ The below file structure is just an example, you can have multiple components su
```markdown
.
└── src/
└── Book/
└── src/
├── Collection/
│ └── BookCollection.php
├── Entity/
│ └── Book.php
├── Handler/
│ └── BookHandler.php
├── InputFilter/
│ ├── Input/
│ │ ├── AuthorInput.php
│ │ ├── NameInput.php
│ │ └── ReleaseDateInput.php
│ └── BookInputFilter.php
├── Repository/
│ └── BookRepository.php
├── Service/
│ ├── BookService.php
│ └── BookServiceInterface.php
├── ConfigProvider.php
└── RoutesDelegator.php
└── Book/
└── src/
├── Collection/
│ └── BookCollection.php
├── Entity/
│ └── Book.php
├── Handler/
│ └── BookHandler.php
├── InputFilter/
│ ├── Input/
│ │ ├── AuthorInput.php
│ │ ├── NameInput.php
│ │ └── ReleaseDateInput.php
│ └── BookInputFilter.php
├── Repository/
│ └── BookRepository.php
├── Service/
│ ├── BookService.php
│ └── BookServiceInterface.php
├── ConfigProvider.php
└── RoutesDelegator.php
```

* `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
Expand Down Expand Up @@ -532,9 +532,14 @@ class BookHandler implements RequestHandlerInterface

Once you set up all the files as in the example above, you will need to do a few additional configurations:

* Register the namespace by adding this line `"Api\\Book\\": "src/Book/src/",` in `composer.json` under the `autoload.psr-4` key.
* Register the module by adding `Api\Book\ConfigProvider::class,` under `Api\User\ConfigProvider::class,`.
* Register the module's routes by adding `\Api\Book\RoutesDelegator::class,` under `\Api\User\RoutesDelegator::class,` in `src/App/src/ConfigProvider.php`.
* register the namespace by adding this line `"Api\\Book\\": "src/Book/src/",` in `composer.json` under the `autoload.psr-4` key
* register the module by adding `Api\Book\ConfigProvider::class,` under `Api\User\ConfigProvider::class,`
* register the module's routes by adding `\Api\Book\RoutesDelegator::class,` under `\Api\User\RoutesDelegator::class,` in `src/App/src/ConfigProvider.php`
* update Composer autoloader by running the command:

```shell
composer dump-autoload
```

It should look like this:

Expand Down Expand Up @@ -641,7 +646,7 @@ curl -X POST http://0.0.0.0:8080/book
-d '{"name": "test", "author": "author name", "releaseDate": "2023-03-03"}'
```

To list the books use :
To list the books use:

```shell
curl http://0.0.0.0:8080/books
Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
docs_dir: docs/book
site_dir: docs/html
extra:
project: "DotKernel API"
project: API
current_version: v4
versions:
- v4
Expand All @@ -18,7 +18,7 @@ nav:
- Tutorials:
- "Creating a book module": v4/tutorials/create-book-module.md
site_name: api
site_description: "DotKernel API"
site_description: DotKernel API
repo_url: "https://github.com/dotkernel/api"
plugins:
- search

0 comments on commit 5095ff9

Please sign in to comment.