# imo-tikuwa/laravel-make-with-format architecture

> Architecture diagram of the GitHub repository imo-tikuwa/laravel-make-with-format, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imo-tikuwa/laravel-make-with-format
- Repository: https://github.com/imo-tikuwa/laravel-make-with-format

## Overview

##### Main Components
- Package Core (src folder):
- LaravelMakeWithFormatServiceProvider: Registers the package into the Laravel application.
- Facade (src/Facades): Provides an accessible interface to the package’s functionality.
- Listeners (src/Listeners/PostCommandCodeFormatter.php): Listens to Laravel’s make:●● command events.
- Services (src/Services) and additional runners (CommandRunner subfolder): Encapsulate the logic to run external processes (Pint and IDE Helper generators).
- Dependencies Checker: Ensures optional tools like Pint and IDE Helper are present.
- Demo Application (demo_app folder):
- A sample Laravel application showing how the package integrates within a real app.
- Includes typical Laravel folders (app, config, routes, etc.) which are used to test and demonstrate the package in action.
- Tests (tests folder):
- Contains architectural tests and service tests ensuring the package behaves as expected.
- Configuration (config folder and publishable config inside demo_app/config):
- Houses any config used to customize the package behavior (likely published using vendor:publish).

##### Relationships and Interactions
- When a developer executes a Laravel "make:" command (e.g., php artisan make:model), the package’s Event Listener is triggered.
- The Service Provider (registered in the package) hooks the listener into Laravel’s event system.
- The Listener then calls the service layer to kick off the appropriate commands:
- It invokes the CommandRunner services (like PintRunner and IdeHelperRunner) to run external processes for code formatting and generating helper files.
- The Dependencies Checker verifies if the optional dependencies (Pint and IDE Helper) are installed. If not, it may bypass running them.
- The Facade exposes these functionalities so that other parts of the Laravel app (or even developers) can interact with the code formatter commands if needed.

##### Architectural Patterns and Design Principles
- Inversion of Control (IoC) via Service Providers, which is standard in Laravel.
- Separation of concerns (listeners, service classes, and runners are distinct, making each component focused on its individual responsibility).
- The use of event-driven architecture (reacting to Laravel artisan commands) to trigger subsequent actions.
- Extensibility: Optional dependencies let the package provide enhanced functionality without forcing them on projects that don’t require it.

##### Technologies, Frameworks, and Libraries
- Laravel Framework (with its artisan command and service container).
- Laravel Pint (for automatic code formatting).
- barryvdh/laravel-ide-helper (for generating IDE helper files).
- Composer for dependency management.
- Docker is also present, indicating containerization support for development or testing.
- Testing frameworks (PHPUnit/Pest) as indicated by the tests folder and phpunit.xml.dist.

- Use clear labels for each component (e.g., “Service Provider,” “Event Listener (PostCommandCodeFormatter),” “CommandRunner – PintRunner,” “Laravel Pint,” “IDE Helper Runner,” “Demo App”).
- From “Artisan Command” → “Service Provider” → “Event Listener.”
- From “Event Listener” → “Service Layer” (CommandProcessService, CommandRunner).
- From “Service Layer” → “External Tools” (Laravel Pint, IDE Helper).
- The demo application environment which illustrates the integration.
- References to configuration and testing components separately.

- Follow it with service provider registration then branch into the “PostCommandCodeFormatter” listener.
- Listener to the services (CommandProcessService and different CommandRunner implementations such as PintRunner and IdeHelperRunner).
- Also incorporate testing components and Docker based on the file tree if necessary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Artisan Command"]:::external
    subgraph "Package Core"
        B["LaravelMakeWithFormatServiceProvider"]:::core
        C["Facade (LaravelMakeWithFormat)"]:::core
        D["Event Listener (PostCommandCodeFormatter)"]:::core
        H["Dependencies Checker"]:::core
        E["Command Process Service"]:::core
        F["Pint Runner"]:::core
        G["IDE Helper Runner"]:::core
    end
    I["Laravel Pint"]:::external
    J["IDE Helper Generator"]:::external
    K["Demo Application"]:::demo
    L["Configuration (make-with-format.php)"]:::config
    M["Testing Suite"]:::test

    A -->|"triggers"| B
    B -->|"hooks"| D
    B -->|"exposes"| C
    D -->|"invokes"| E
    H -->|"validates for"| E
    E -->|"runs"| F
    E -->|"runs"| G
    F -->|"calls"| I
    G -->|"calls"| J
    B -->|"integrated in"| K
    K -->|"customizes"| L
    B -->|"verified by"| M

    click B "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/src/LaravelMakeWithFormatServiceProvider.php"
    click C "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/src/Facades/LaravelMakeWithFormat.php"
    click D "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/src/Listeners/PostCommandCodeFormatter.php"
    click E "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/src/Services/CommandProcessService.php"
    click F "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/src/Services/CommandRunner/PintRunner.php"
    click G "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/src/Services/CommandRunner/IdeHelperRunner.php"
    click H "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/src/Services/DependenciesChecker.php"
    click K "https://github.com/imo-tikuwa/laravel-make-with-format/tree/main/demo_app"
    click L "https://github.com/imo-tikuwa/laravel-make-with-format/blob/main/config/make-with-format.php"
    click M "https://github.com/imo-tikuwa/laravel-make-with-format/tree/main/tests"

    classDef core fill:#cce5ff,stroke:#0069d9,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef demo fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef config fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef test fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
```
