{"id":24806607,"url":"https://github.com/kernelfolla/exercise-php-whois-query-service","last_synced_at":"2026-08-12T17:32:04.612Z","repository":{"id":274368295,"uuid":"922643464","full_name":"KernelFolla/exercise-php-whois-query-service","owner":"KernelFolla","description":"A PHP-based WHOIS query service for .com domains, built as an exercise using Slim Framework and DDD Hexagonal Architecture. Includes a RESTful API, Docker support, and unit/integration tests.","archived":false,"fork":false,"pushed_at":"2025-01-26T21:03:32.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-12T05:53:03.919Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KernelFolla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-26T18:35:48.000Z","updated_at":"2025-01-26T21:03:37.000Z","dependencies_parsed_at":"2025-01-26T22:28:19.358Z","dependency_job_id":null,"html_url":"https://github.com/KernelFolla/exercise-php-whois-query-service","commit_stats":null,"previous_names":["kernelfolla/exercise-php-whois-query-service"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KernelFolla/exercise-php-whois-query-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelFolla%2Fexercise-php-whois-query-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelFolla%2Fexercise-php-whois-query-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelFolla%2Fexercise-php-whois-query-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelFolla%2Fexercise-php-whois-query-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KernelFolla","download_url":"https://codeload.github.com/KernelFolla/exercise-php-whois-query-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelFolla%2Fexercise-php-whois-query-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36575908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-08-06T04:43:03.162Z","status":"online","status_checked_at":"2026-08-12T02:00:07.134Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-30T08:29:21.029Z","updated_at":"2026-08-12T17:32:04.597Z","avatar_url":"https://github.com/KernelFolla.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WHOIS Query Service Exercise (.com Domains)\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nThis is an exercise to implement a PHP-based WHOIS query service for `.com` domains using the **Slim Framework**. The service is structured following **Domain-Driven Design (DDD) Hexagonal Architecture** and includes Docker support for containerization. It also features unit and integration tests to validate functionality.\n\n---\n\n## Features\n\n- **RESTful API Endpoint**: Accepts HTTP GET requests to perform WHOIS queries on `.com` domains.\n- **Error Handling**: Returns appropriate HTTP status codes for invalid domains, non-`.com` domains, or other errors, conforming to REST API standards.\n- **Hexagonal Architecture**: Follows DDD principles for clean separation of concerns and maintainability.\n- **Docker Support**: Fully containerized for easy deployment and execution.\n- **Testing**:\n    - **Unit Tests**: Validate domain logic and use cases.\n    - **Integration Tests**: Ensure proper integration with the WHOIS service.\n\n### NOTE\n\nI've not used php-di for dependency injection, as it's not necessary for this exercise. However, it would be a good addition for a more complex application. Also I've not used any ORM/persistence for the same reason, but it would be a good addition for a more complex application.\n\n### Hexagonal Architecture and Domain-Driven Design (DDD) Implementation\n\nThis project follows the principles of **Hexagonal Architecture** and **Domain-Driven Design (DDD)** to ensure a clean separation of concerns and maintainability. The project is structured into several layers, each with specific responsibilities.\n\n---\n\n#### Layers\n\n##### Domain Layer\nThe **Domain layer** encapsulates the core business logic and rules. It includes entities, value objects, and domain services. For example:\n\n- **DomainName** (`src/Domain/ValueObject/DomainName.php`): A value object representing a domain name, ensuring it is valid and a `.com` domain.\n- **Domain** (`src/Domain/Entity/Domain.php`): An entity representing a domain with its associated properties.\n\n##### Application Layer\nThe **Application layer** contains application services and use cases that orchestrate the domain logic. It acts as a mediator between the domain and the outside world. For example:\n\n- **WhoisService** (`src/Application/Service/WhoisService.php`): A service that handles WHOIS queries by interacting with the domain and infrastructure layers.\n- **WhoisQuery** (`src/Application/Query/WhoisQuery.php`): A query object used to encapsulate the parameters for a WHOIS query.\n\n##### Infrastructure Layer\nThe **Infrastructure layer** provides implementations for external systems and frameworks, such as HTTP controllers and WHOIS service adapters. For example:\n\n- **WhoisController** (`src/Infrastructure/Http/Controller/WhoisController.php`): An HTTP controller that handles requests for WHOIS queries.\n- **WhoisAdapter** (`src/Infrastructure/Adapter/WhoisAdapter.php`): An adapter that connects to the WHOIS server to perform queries.\n\n##### Port Layer\nThe **Port layer** defines interfaces (ports) that the Domain layer depends on, allowing the Infrastructure layer to provide specific implementations (adapters). For example:\n\n- **WhoisServiceInterface** (`src/Domain/Port/WhoisServiceInterface.php`): An interface defining the contract for a service that performs WHOIS queries.\n\n---\n\n#### Key Concepts\n\n##### Inbound and Outbound Ports\n- **Inbound Ports**: These are interfaces that define how external systems (like HTTP requests) can interact with the application. For example, the `WhoisController` acts as an inbound port, accepting HTTP requests and delegating them to the application layer.\n- **Outbound Ports**: These are interfaces that define how the application interacts with external systems (like databases or third-party services). For example, the `WhoisServiceInterface` is an outbound port that defines how the application interacts with a WHOIS service.\n\n##### Adapters\n- **Adapters**: Adapters are implementations of inbound or outbound ports. They act as a bridge between the application and external systems. For example:\n    - The `WhoisAdapter` (`src/Infrastructure/Adapter/WhoisAdapter.php`) is an outbound adapter that implements the `WhoisServiceInterface` and communicates with the WHOIS server.\n    - The `WhoisController` (`src/Infrastructure/Http/Controller/WhoisController.php`) is an inbound adapter that handles HTTP requests and translates them into application commands.\n\n---\n\n#### Example Files\n\n- **Domain Layer**:\n    - `src/Domain/ValueObject/DomainName.php`: Contains the `DomainName` value object.\n    - `src/Domain/Entity/Domain.php`: Contains the `Domain` entity.\n\n- **Application Layer**:\n    - `src/Application/Service/WhoisService.php`: Contains the `WhoisService` application service.\n    - `src/Application/Query/WhoisQuery.php`: Contains the `WhoisQuery` query object.\n\n- **Infrastructure Layer**:\n    - `src/Infrastructure/Http/Controller/WhoisController.php`: Contains the `WhoisController` HTTP controller.\n    - `src/Infrastructure/Adapter/WhoisAdapter.php`: Contains the `WhoisAdapter` WHOIS service adapter.\n\n- **Port Layer**:\n    - `src/Domain/Port/WhoisServiceInterface.php`: Contains the `WhoisServiceInterface` port.\n\n---\n\n#### Benefits of This Structure\n\n- **Testability**: The core domain logic is decoupled from external dependencies, making it easy to test.\n- **Flexibility**: The use of ports and adapters allows for easy swapping of implementations.\n- **Maintainability**: Each layer has a clear responsibility, making the codebase more maintainable and scalable.\n\n---\n\nThis structure ensures a clean separation of concerns, making the project robust, maintainable, and ready for future extensions.\n\n---\n\n### OpenAPI Specification\n\nThis project includes an **OpenAPI specification** (`openapi.yaml`) that defines the API endpoints and their expected behavior. The OpenAPI specification provides a standard way to describe the RESTful API, making it easier for developers to understand and interact with the service.\n\nYou can view and interact with the OpenAPI documentation using tools like **Swagger UI** or **Redoc**. To do this, you can use one the following links:\n\n- [https://editor-next.swagger.io/?url=https://raw.githubusercontent.com/KernelFolla/exercise-php-whois-query-service/main/openapi.yaml](https://editor-next.swagger.io/?url=https://raw.githubusercontent.com/KernelFolla/exercise-php-whois-query-service/main/openapi.yaml)\n- [https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/KernelFolla/exercise-php-whois-query-service/main/openapi.yaml](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/KernelFolla/exercise-php-whois-query-service/main/openapi.yaml)\n- [https://editor.swagger.io/?url=https://raw.githubusercontent.com/KernelFolla/exercise-php-whois-query-service/main/openapi.yaml](https://editor.swagger.io/?url=https://raw.githubusercontent.com/KernelFolla/exercise-php-whois-query-service/main/openapi.yaml)\n\n## Requirements\n\n- Docker and Docker Compose\n\n---\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/KernelFolla/exercise-php-whois-query-service.git\n   cd whois-query-service-exercise\n   ```\n\n## Usage\n\n### Starting the Service\n\n```bash\nmake start\n```\n\n### Stopping the Service\n\n```bash\nmake stop\n```\n\n### Using Composer\n\nYou can run Composer commands using the `make` command. For example, to install dependencies, run:\n```bash\nmake composer install\n```\n\nYou can also pass additional parameters to Composer commands. For example:\n```bash\nmake composer install --no-dev\n```\n\n### Running PHPStan\n\nTo run PHPStan for static analysis, use:\n```bash\nmake phpstan\n```\n\n### Running PHPCS\n\nTo run PHP CodeSniffer for code style checks, use:\n```bash\nmake phpcs\n```\n\nto fix the code style issues automatically, use:\n```bash\nmake phpcs-fix\n```\n\n## Contributing\n\nThis is an exercise, so contributions are not expected. However, feedback and suggestions are welcome!\n\n---\n\n## Author\n\n- **[Marino Di Clemente](https://github.com/KernelFolla)**\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkernelfolla%2Fexercise-php-whois-query-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkernelfolla%2Fexercise-php-whois-query-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkernelfolla%2Fexercise-php-whois-query-service/lists"}