Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions docs/book/v1/how-to/communication-with-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Communication with the [`Dotkernel Queue`](https://github.com/dotkernel/queue)

The main advantage of the procedural code is its simplicity, it directly connects to the queue server, sends the prepared data, and then closes the connection. In this example, the code opens a TCP connection to `localhost:8556`, checks if the connection is successful, sends data in JSON format, and closes the socket. This makes the logic easy to follow and quick to implement. The disadvantage of this approach is the difficulty of reusing and extending the code. As the complexity of the project increases by repeatedly using this approach, the code becomes more difficult to maintain and not as flexible compared to the object-oriented approach.

```shell
```php
// collect the PAYLOAD that will be sent to Dotkernel Queue
$data = $anyTypeOfData;

Expand Down Expand Up @@ -44,7 +44,7 @@ Inside it, create a new `ConfigProvider.php`, a new `NotificationService.php` an

ConfigProvider code:

```shell
```php
<?php

declare(strict_types=1);
Expand Down Expand Up @@ -90,7 +90,7 @@ class ConfigProvider

Service code:

```shell
```php
<?php

declare(strict_types=1);
Expand Down Expand Up @@ -151,9 +151,13 @@ class NotificationService

After you have finished creating the new files, navigate to composer.json and add the new dependencies under the require key:

```shell
"ext-sockets": "*",
"clue/socket-raw": "^v1.6.0",
```json
{
"require": {
"ext-sockets": "*",
"clue/socket-raw": "^1.6.0"
}
}
```

Install new dependencies using:
Expand All @@ -164,7 +168,7 @@ composer install

Under the `autoload` → `psr-4` key add the newly created module:

```shell
```php
"Core\\NotificationSystem\\": "src/Core/src/NotificationSystem/src"
```

Expand All @@ -177,7 +181,7 @@ Navigate to `config/config.php` and add your new Core ConfigProvider `Core\Notif
After you have added the new config provider, navigate to `config/autoload/local.php` and add a new config key used for server connection.
> **_NOTE:_** if you only have the local.php.dist file, duplicate it, and delete .dist from the copy's name.

```shell
```php
'notification' => [
'server' => [
'protocol' => 'tcp',
Expand All @@ -192,7 +196,7 @@ After you have added the new config provider, navigate to `config/autoload/local

Navigate to your handler, inject the new service and use your custom method where needed.

```shell
```php
#[Inject(
NotificationService::class
)]
Expand Down
46 changes: 25 additions & 21 deletions docs/book/v1/how-to/send-emails.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,35 @@ Importing the Core is essential for the queue to communicate with the main appli

After adding the Core, you need to make sure all external dependencies are included in composer.json. Without them, Core functionalities (cache, mail, authentication, etc.) won’t work in the queue.

```shell
"dotkernel/dot-cache": "^4.3",
"dotkernel/dot-data-fixtures": "^1.4.0",
"dotkernel/dot-errorhandler": "4.2.1",
"dotkernel/dot-mail": "^5.3.0",
"laminas/laminas-authentication": "2.18.0",
"mezzio/mezzio-authentication-oauth2": "^2.11",
"mezzio/mezzio-twigrenderer": "^2.17.0",
"ramsey/uuid": "^4.5.0",
"ramsey/uuid-doctrine": "^2.1.0",
"roave/psr-container-doctrine": "^5.2.2",
```json
{
"dotkernel/dot-cache": "^4.3",
"dotkernel/dot-data-fixtures": "^1.4.0",
"dotkernel/dot-errorhandler": "4.2.1",
"dotkernel/dot-mail": "^5.3.0",
"laminas/laminas-authentication": "2.18.0",
"mezzio/mezzio-authentication-oauth2": "^2.11",
"mezzio/mezzio-twigrenderer": "^2.17.0",
"ramsey/uuid": "^4.5.0",
"ramsey/uuid-doctrine": "^2.1.0",
"roave/psr-container-doctrine": "^5.2.2"
}
```

Adding Core modules under `autoload` → `psr-4` enables automatic class loading, so you don’t have to manually require each class.

```shell
"autoload": {
```json
{
"autoload": {
"psr-4": {
"Queue\\": "src/",
"Core\\Admin\\": "src/Core/src/Admin/src",
"Core\\App\\": "src/Core/src/App/src",
"Core\\Security\\": "src/Core/src/Security/src",
"Core\\Setting\\": "src/Core/src/Setting/src",
"Core\\User\\": "src/Core/src/User/src",
"Queue\\": "src/",
"Core\\Admin\\": "src/Core/src/Admin/src",
"Core\\App\\": "src/Core/src/App/src",
"Core\\Security\\": "src/Core/src/Security/src",
"Core\\Setting\\": "src/Core/src/Setting/src",
"Core\\User\\": "src/Core/src/User/src",
}
}
}
```

Expand All @@ -61,7 +65,7 @@ Running `composer install` ensures that all packages required for Core and the q

Navigate to `config/config.php` and add `ConfigProvider::class` file from all packages you installed.

```shell
```php
Mezzio\Twig\ConfigProvider::class,
Dot\Cache\ConfigProvider::class,
Dot\DataFixtures\ConfigProvider::class,
Expand All @@ -80,7 +84,7 @@ Core\User\ConfigProvider::class,
Navigate to `config/autoload/local.php` and fill in the database connection details.
> **_NOTE:_** if you only have the local.php.dist file, duplicate it, and delete .dist from the copy's name.

```shell
```php
$databases = [
'default' => [
'host' => '',
Expand Down