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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"require-dev": {
"deptrac/deptrac": "^4.4",
"laravel/pint": "^1.26",
"monolog/monolog": "^3.9",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.5"
},
Expand Down
61 changes: 39 additions & 22 deletions deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,38 @@ deptrac:
paths:
- ./src
layers:
- name: Toolkit
- name: Application
collectors:
- type: classLike
value: CloudCreativity\\Modules\\Contracts\\Toolkit\\*
value: CloudCreativity\\Modules\\Contracts\\Application\\*
- type: classLike
value: CloudCreativity\\Modules\\Toolkit\\*
value: CloudCreativity\\Modules\\Application\\*
- name: Bus
collectors:
- type: classLike
value: Ramsey\\Uuid\\*
value: CloudCreativity\\Modules\\Contracts\\Bus\\*
- type: classLike
value: CloudCreativity\\Modules\\Bus\\*
- name: Domain
collectors:
- type: classLike
value: CloudCreativity\\Modules\\Contracts\\Domain\\*
- type: classLike
value: CloudCreativity\\Modules\\Domain\\*
- name: Application
collectors:
- type: classLike
value: CloudCreativity\\Modules\\Contracts\\Application\\*
- type: classLike
value: CloudCreativity\\Modules\\Application\\*
- name: Infrastructure
collectors:
- type: classLike
value: CloudCreativity\\Modules\\Contracts\\Infrastructure\\*
- type: classLike
value: CloudCreativity\\Modules\\Infrastructure\\*
- type: classLike
value: Monolog\\*
- name: Messaging
collectors:
- type: classLike
value: CloudCreativity\\Modules\\Contracts\\Messaging\\*
- type: classLike
value: CloudCreativity\\Modules\\Messaging\\*
- name: PSR Container
collectors:
- type: classLike
Expand All @@ -36,27 +42,38 @@ deptrac:
collectors:
- type: classLike
value: Psr\\Log\\*
- name: Attributes
- name: Toolkit
collectors:
- type: classLike
value: CloudCreativity\\Modules\\Contracts\\Toolkit\\*
- type: classLike
value: CloudCreativity\\Modules\\Toolkit\\*
- type: classLike
value: Ramsey\\Uuid\\*
- type: classLike
value: ^Deprecated$
ruleset:
Toolkit:
- Attributes
- PSR Container
Domain:
- Toolkit
- Attributes
Application:
- Toolkit
- Bus
- Domain
- Messaging
- PSR Container
- PSR Log
- Attributes
Infrastructure:
- Toolkit
- Domain
Bus:
- Messaging
- PSR Container
- PSR Log
- Toolkit
Domain:
- Toolkit
Infrastructure:
- Application
- Bus
- Messaging
- PSR Container
- PSR Log
- Attributes
- Toolkit
Messaging:
- Toolkit
Toolkit:
7 changes: 3 additions & 4 deletions docs/guide/application/asynchronous-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ And then our port adapter is as follows:
```php
namespace App\Modules\EventManagement\Application\Bus;

use App\Modules\EventManagement\Application\Ports\Driven\Queue\InternalCommandBus;
use CloudCreativity\Modules\Application\Bus\CommandDispatcher;
use App\Modules\EventManagement\Application\Ports\Driven\Queue\InternalCommandBus;use CloudCreativity\Modules\Bus\CommandDispatcher;

final class InternalCommandBusAdapter extends CommandDispatcher implements
InternalCommandBus
Expand All @@ -221,7 +220,7 @@ public commands. I.e.:
```php
namespace App\Modules\EventManagement\Application\Ports\Driven\Queue;

use CloudCreativity\Modules\Contracts\Application\Ports\Driven\Queue as Port;
use CloudCreativity\Modules\Contracts\Application\Ports\Queue as Port;

// injected into the command queuer for queuing public commands
interface Queue extends Port
Expand All @@ -239,4 +238,4 @@ internal bus - to dispatch the command to when it is pulled from the queue.

If you prefer, it is acceptable to define a single queue driven port. This simplifies the implementation by having a
single queue that deals with both. However, you might find it gets complicated knowing whether to dispatch queued
commands to either the public or internal command bus.
commands to either the public or internal command bus.
57 changes: 14 additions & 43 deletions docs/guide/application/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ For example:
```php
namespace App\Modules\EventManagement\Application\UseCases\Commands\CancelAttendeeTicket;

use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier;
use CloudCreativity\Modules\Contracts\Toolkit\Messages\Command;
use VendorName\EventManagement\Shared\Enums\CancellationReasonEnum;
use CloudCreativity\Modules\Contracts\Messaging\Command;use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier;use VendorName\EventManagement\Shared\Enums\CancellationReasonEnum;

final readonly class CancelAttendeeTicketCommand implements Command
{
Expand Down Expand Up @@ -52,10 +50,7 @@ For example:
```php
namespace App\Modules\EventManagement\Application\UseCases\Commands\CancelAttendeeTicket;

use App\Modules\EventManagement\Application\Ports\Driven\Persistence\AttendeeRepository;
use CloudCreativity\Modules\Application\Bus\Middleware\ExecuteInUnitOfWork;
use CloudCreativity\Modules\Contracts\Application\Messages\DispatchThroughMiddleware;
use CloudCreativity\Modules\Toolkit\Results\Result;
use App\Modules\EventManagement\Application\Ports\Driven\Persistence\AttendeeRepository;use CloudCreativity\Modules\Application\Bus\Middleware\ExecuteInUnitOfWork;use CloudCreativity\Modules\Contracts\Bus\DispatchThroughMiddleware;use CloudCreativity\Modules\Toolkit\Results\Result;

final readonly class CancelAttendeeTicketHandler implements
DispatchThroughMiddleware
Expand Down Expand Up @@ -142,8 +137,7 @@ And then our implementation is as follows:
```php
namespace App\Modules\EventManagement\Application\Bus;

use App\Modules\EventManagement\Application\Ports\Driving\CommandBus as Port;
use CloudCreativity\Modules\Application\Bus\CommandDispatcher;
use App\Modules\EventManagement\Application\Ports\Driving\CommandBus as Port;use CloudCreativity\Modules\Bus\CommandDispatcher;

final class CommandBus extends CommandDispatcher implements Port
{
Expand All @@ -167,16 +161,7 @@ For example:
```php
namespace App\Modules\EventManagement\Application\Bus;

use App\Modules\EventManagement\Application\UsesCases\Commands\{
CancelAttendeeTicket\CancelAttendeeTicketCommand,
CancelAttendeeTicket\CancelAttendeeTicketHandler,
};
use App\Modules\EventManagement\Application\Ports\Driving\CommandBus as CommandBusPort;
use App\Modules\EventManagement\Application\Ports\Driven\DependencyInjection\ExternalDependencies;
use CloudCreativity\Modules\Application\Bus\CommandHandlerContainer;
use CloudCreativity\Modules\Application\Bus\Middleware\ExecuteInUnitOfWork;
use CloudCreativity\Modules\Application\Bus\Middleware\LogMessageDispatch;
use CloudCreativity\Modules\Toolkit\Pipeline\PipeContainer;
use App\Modules\EventManagement\Application\Ports\Driven\DependencyInjection\ExternalDependencies;use App\Modules\EventManagement\Application\Ports\Driving\CommandBus as CommandBusPort;use App\Modules\EventManagement\Application\UsesCases\Commands\{CancelAttendeeTicket\CancelAttendeeTicketCommand,CancelAttendeeTicket\CancelAttendeeTicketHandler,};use CloudCreativity\Modules\Application\Bus\Middleware\ExecuteInUnitOfWork;use CloudCreativity\Modules\Bus\CommandHandlerContainer;use CloudCreativity\Modules\Bus\Middleware\LogMessageDispatch;use CloudCreativity\Modules\Toolkit\Pipeline\PipeContainer;

final class CommandBusProvider
{
Expand Down Expand Up @@ -343,9 +328,7 @@ And then our implementation is as follows:
```php
namespace App\Modules\EventManagement\Application\Bus;

use App\Modules\EventManagement\Application\Ports\Driving\CommandQueuer as Port;
use App\Modules\EventManagement\Application\Ports\Driven\Queue;
use CloudCreativity\Modules\Application\Bus\CommandQueuer as Queuer;
use App\Modules\EventManagement\Application\Ports\Driven\Queue;use App\Modules\EventManagement\Application\Ports\Driving\CommandQueuer as Port;use CloudCreativity\Modules\Application\Bus\CommandQueuer as Queuer;

final class CommandQueuer extends Queuer implements Port
{
Expand Down Expand Up @@ -466,8 +449,7 @@ singleton instances of dependencies.
For example:

```php
use App\Modules\EventManagement\Domain\Services;
use CloudCreativity\Modules\Application\Bus\Middleware\SetupBeforeDispatch;
use App\Modules\EventManagement\Domain\Services;use CloudCreativity\Modules\Bus\Middleware\SetupBeforeDispatch;

$middleware->bind(
SetupBeforeDispatch::class,
Expand Down Expand Up @@ -497,7 +479,7 @@ If you only need to do teardown work, use the `TeardownAfterDispatch` middleware
closure as its only constructor argument:

```php
use CloudCreativity\Modules\Application\Bus\Middleware\TeardownAfterDispatch;
use CloudCreativity\Modules\Bus\Middleware\TeardownAfterDispatch;

$middleware->bind(
TeardownAfterDispatch::class,
Expand Down Expand Up @@ -578,7 +560,7 @@ Use our `LogMessageDispatch` middleware to log the dispatch of a command, and th
[PSR Logger](https://php-fig.org/psr/psr-3/).

```php
use CloudCreativity\Modules\Application\Bus\Middleware\LogMessageDispatch;
use CloudCreativity\Modules\Bus\Middleware\LogMessageDispatch;

$middleware->bind(
LogMessageDispatch::class,
Expand Down Expand Up @@ -620,9 +602,7 @@ However, there may be scenarios where a property should not be logged, e.g. beca
In this scenario, use the `Sensitive` attribute on the property, and it will not be logged:

```php
use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier;
use CloudCreativity\Modules\Contracts\Toolkit\Messages\Command;
use CloudCreativity\Modules\Toolkit\Loggable\Sensitive;
use CloudCreativity\Modules\Toolkit\Sensitive;use CloudCreativity\Modules\Contracts\Messaging\Command;use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier;

final readonly class CancelAttendeeTicketCommand implements Command
{
Expand All @@ -638,9 +618,7 @@ final readonly class CancelAttendeeTicketCommand implements Command
If you need full control over the log context, implement the `ContextProvider` interface on your command message:

```php
use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier;
use CloudCreativity\Modules\Contracts\Toolkit\Loggable\ContextProvider;
use CloudCreativity\Modules\Contracts\Toolkit\Messages\Command;
use CloudCreativity\Modules\Contracts\Bus\Loggable\ContextProvider;use CloudCreativity\Modules\Contracts\Messaging\Command;use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier;

final readonly class CancelAttendeeTicketCommand implements
Command,
Expand Down Expand Up @@ -670,10 +648,7 @@ following signature:
```php
namespace App\Modules\EventManagement\Application\Bus\Middleware;

use Closure;
use CloudCreativity\Modules\Contracts\Application\Bus\CommandMiddleware;
use CloudCreativity\Modules\Contracts\Toolkit\Messages\Command;
use CloudCreativity\Modules\Contracts\Toolkit\Result\Result;
use Closure;use CloudCreativity\Modules\Contracts\Bus\Middleware\CommandMiddleware;use CloudCreativity\Modules\Contracts\Messaging\Command;use CloudCreativity\Modules\Contracts\Toolkit\Result\Result;

final class MyMiddleware implements CommandMiddleware
{
Expand All @@ -685,7 +660,7 @@ final class MyMiddleware implements CommandMiddleware
* @return Result<mixed>
*/
public function __invoke(
Command $command,
Command $command,
Closure $next,
): Result
{
Expand All @@ -712,11 +687,7 @@ instead:
```php
namespace App\Modules\EventManagement\Application\Bus\Middleware;

use Closure;
use CloudCreativity\Modules\Contracts\Application\Bus\BusMiddleware;
use CloudCreativity\Modules\Contracts\Toolkit\Messages\Command;
use CloudCreativity\Modules\Contracts\Toolkit\Messages\Query;
use CloudCreativity\Modules\Contracts\Toolkit\Result\Result;
use Closure;use CloudCreativity\Modules\Contracts\Bus\Middleware\BusMiddleware;use CloudCreativity\Modules\Contracts\Messaging\Command;use CloudCreativity\Modules\Contracts\Messaging\Query;use CloudCreativity\Modules\Contracts\Toolkit\Result\Result;

class MyBusMiddleware implements BusMiddleware
{
Expand All @@ -728,7 +699,7 @@ class MyBusMiddleware implements BusMiddleware
* @return Result<mixed>
*/
public function __invoke(
Command|Query $message,
Command|Query $message,
Closure $next,
): Result
{
Expand Down
Loading