Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 3780f7a

Browse files
Refactor SDK for enhanced modularity, consistency, and functionality
- Removed `EndpointBuilder` class and replaced with `ApiPathEnum` for unified API path management. - Standardized method signatures with improved naming conventions (e.g., `listener` -> `listenerName`, `name` -> `applicationName`). - Introduced `Telemetry` class and `TelemetryProtocolEnum` for telemetry handling. - Added support for managing modules in `Statistics` class and integrated `ModuleStatistics` implementation. - Refactored `CanUpload` trait, added missing exceptions, and enhanced upload/remove methods with fallbacks for missing configs. - Refined tests for proper mocking, coverage, and PHP 8.x compatibility. - Updated default values and constructors for enhanced flexibility across configuration classes.
2 parents 6ec7aa5 + a411472 commit 3780f7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+970
-307
lines changed

.github/SECURITY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ We use [SemVer](https://semver.org/) for versioning. For the versions available,
88

99
| Version | Nginx Unit Capability | Supported |
1010
|---------|:----------------------|--------------------|
11+
| 0.9.x | >=1.33.0 | :white_check_mark: |
1112
| 0.8.x | 1.32.1 | :white_check_mark: |
1213
| < 0.7.x | - | :x: |
1314

.github/workflows/deploy_codecov.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.3'
19+
php-version: '8.4'
2020
extensions: curl
2121
tools: composer:v2
2222
coverage: xdebug

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## v0.9.0 - [2025/09/20]
4+
5+
- Added new class `Telemetry` and `TelemetryProtocolEnum` for telemetry support
6+
- Added `ModuleStatisticsInterface` and class `ModuleStatistics` for module statistics
7+
- Added enum ApiPathEnum for managing API paths
8+
- Added methods `getRouteBlock` and `removeRouteBlock` in `Route` class
9+
310
## v0.8.0 - [2024/09/10]
411

512
- Updated application classes

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
<p align="center">
1010
<a href="https://packagist.org/packages/pavlusha311245/unit-php-sdk"><img src="https://img.shields.io/packagist/v/Pavlusha311245/unit-php-sdk?labelColor=%231e293b&color=%23702963&link=https%3A%2F%2Fpackagist.org%2Fpackages%2Fpavlusha311245%2Funit-php-sdk" alt="packagist link"></a>
11-
<a href="https://unit-sdk.pavlusha.me/"><img src="https://img.shields.io/website?url=https%3A%2F%2Funit-sdk.pavlusha.me%2F&label=documentation&link=https%3A%2F%2Funit-sdk.pavlusha.me%2F" alt="documentation link"></a>
1211
<img src="https://github.com/Pavlusha311245/nginx-unit-php-sdk/actions/workflows/deploy_codecov.yaml/badge.svg" alt="documentation link">
1312
<a href="https://codecov.io/gh/Pavlusha311245/nginx-unit-php-sdk" >
1413
<img src="https://codecov.io/gh/Pavlusha311245/nginx-unit-php-sdk/graph/badge.svg?token=FGTTDSJ7BX" alt="Codecov dabge"/>
1514
</a>
15+
<a href="https://deepwiki.com/Pavlusha311245/nginx-unit-php-sdk"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
1616
</p>
1717

1818
## About
@@ -30,7 +30,8 @@ server management into your projects
3030

3131
| Version | Nginx Unit Capability | Supported |
3232
|---------|:----------------------|--------------------|
33-
| 0.8.x | <= 1.32.1 | :white_check_mark: |
33+
| 0.9.x | >= 1.33.0 | :white_check_mark: |
34+
| 0.8.x | <= 1.32.1 | :x: |
3435
| < 0.7.x | - | :x: |
3536

3637
### Quick start

composer.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pavlusha/unit-php-sdk",
3-
"version": "0.8.0",
3+
"version": "0.9.0",
44
"type": "sdk",
55
"description": "This project allows developers to interact with the Nginx Unit web server through PHP classes",
66
"license": "Apache-2.0",
@@ -19,27 +19,28 @@
1919
],
2020
"scripts": {
2121
"test": [
22-
"composer test:unit",
23-
"composer test:phpstan"
22+
"@test:phpstan",
23+
"@test:unit"
2424
],
2525
"test:unit": "./vendor/bin/pest",
26-
"test:coverage": "./vendor/bin/pest --coverage --coverage-clover coverage.xml",
27-
"test:phpstan": "./vendor/bin/phpstan analyse -c phpstan.neon",
28-
"lint": "./vendor/bin/php-cs-fixer fix --rules=@PSR12 ."
26+
"test:coverage": "XDEBUG_MODE=cover ./vendor/bin/pest --coverage --coverage-clover coverage.xml",
27+
"test:phpstan": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=256M",
28+
"lint": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --rules=@PSR12 ."
2929
},
3030
"require": {
31-
"php": "^8.3",
32-
"friendsofphp/php-cs-fixer": "^3.54",
33-
"guzzlehttp/guzzle": "^7.8.1",
34-
"nesbot/carbon": "^2.72",
31+
"php": "^8.4",
32+
"friendsofphp/php-cs-fixer": "^3.68",
33+
"guzzlehttp/guzzle": "^7.9",
34+
"nesbot/carbon": "^3.8",
3535
"doctrine/inflector": "^2.0",
3636
"ext-curl": "*"
3737
},
3838
"require-dev": {
39-
"pestphp/pest": "^2.34",
40-
"phpstan/phpstan": "^1.10",
39+
"roave/security-advisories": "dev-latest",
40+
"pestphp/pest": "^2.36",
41+
"phpstan/phpstan": "^1.12",
4142
"mockery/mockery": "^1.6",
42-
"fakerphp/faker": "^1.23"
43+
"fakerphp/faker": "^1.24"
4344
},
4445
"autoload": {
4546
"psr-4": {

src/Abstract/AbstractApplication.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ProcessManagement\RequestLimit
88
};
99
use UnitPhpSdk\Builders\EndpointBuilder;
10+
use UnitPhpSdk\Enums\ApiPathEnum;
1011
use UnitPhpSdk\Exceptions\UnitException;
1112
use UnitPhpSdk\Contracts\{ApplicationInterface, Arrayable, Uploadable};
1213
use UnitPhpSdk\Traits\CanUpload;
@@ -99,7 +100,7 @@ public function __construct(string $name, ?array $data = [])
99100
$this->parseFromArray($data);
100101
}
101102

102-
$this->setApiEndpoint(EndpointBuilder::create("config/applications/")->get() . $this->getName());
103+
$this->setApiEndpoint(ApiPathEnum::APPLICATION->getPath($this->getName()));
103104
}
104105

105106
/**

src/Builders/ApplicationBuilder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
class ApplicationBuilder
1818
{
1919
/**
20-
* @throws UnitException
21-
*
22-
* TODO: add ApplicationTypeEnum as possible type
20+
* @param $appName
21+
* @param $appData
22+
* @param string $type
23+
* @return GoExternalApplication|JavaApplication|NodeJsExternalApplication|PerlApplication|PhpApplication|PythonApplication|RubyApplication|WebAssemblyApplication|WebAssemblyComponentApplication
2324
*/
2425
public static function create($appName, $appData, string $type = '')
2526
{

src/Builders/EndpointBuilder.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/Certificate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @implements CertificateInterface
1515
*/
16-
readonly class Certificate implements CertificateInterface, Arrayable
16+
class Certificate implements CertificateInterface, Arrayable
1717
{
1818
/**
1919
* @var array $chain

0 commit comments

Comments
 (0)