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
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# PHP files always use LF, which the coding-style check enforces
*.php text eol=lf

# Keep development files out of the Composer package
/.github export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/ROADMAP.md export-ignore
132 changes: 132 additions & 0 deletions .github/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Tests

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
quality:
name: Coding style and static analysis
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
tools: composer:v2

- name: Install dependencies
uses: ramsey/composer-install@v3
with:
composer-options: --prefer-dist

- name: Check coding style
run: vendor/bin/php-cs-fixer check --diff

- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress --error-format=github

phpunit:
name: PHP ${{ matrix.php }} (${{ matrix.dependencies }} deps)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4', '8.5']
dependencies: [highest]
include:
- php: '8.2'
dependencies: lowest

steps:
- uses: actions/checkout@v5

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
tools: composer:v2

- name: Install dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist

- name: Run tests
run: vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload coverage
if: matrix.php == '8.4' && matrix.dependencies == 'highest'
uses: codecov/codecov-action@v5
with:
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
composer.lock
test.php
/vendor
/tests/log
/tests/log
/.phpunit.cache
coverage.xml
/.phpstan.cache
.php-cs-fixer.cache
28 changes: 28 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([__DIR__ . '/src', __DIR__ . '/tests']);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setIndent("\t")
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache')
->setRules([
'@PSR12' => true,
// Opening braces stay on the same line, with a blank line after a class opening brace
'braces_position' => [
'classes_opening_brace' => 'same_line',
'functions_opening_brace' => 'same_line',
'anonymous_classes_opening_brace' => 'same_line',
'anonymous_functions_opening_brace' => 'same_line',
'control_structures_opening_brace' => 'same_line',
],
'no_blank_lines_after_class_opening' => false,
'array_syntax' => ['syntax' => 'short'],
'no_unused_imports' => true,
'single_quote' => true,
'no_trailing_comma_in_singleline' => true,
'single_line_empty_body' => true,
'declare_strict_types' => true,
])
->setFinder($finder);
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

85 changes: 85 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Changelog

All notable changes to this project are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

This will be released as 2.0.0. It brings the library up to date with HestiaCP 1.10 and contains breaking changes, marked **BC break** below.

### Added

- Database module (`Client::getModuleDatabase()`): `add()`, `delete()`, `deleteDatabases()`, `listDatabase()` and `listDatabases()`.
- Access-key authentication (HestiaCP 1.6+). Named constructors `Credentials::accessKey($key, $secret)`, `Credentials::legacyHash($hash)` and `Credentials::password($user, $pass)`. `ACCESS_KEY:SECRET_KEY` can also be passed as a single string to `Client::simpleFactory()`.
- `verify` client option: `true` (default), `false`, or a path to a CA bundle.
- Missing exit codes in `ResponseCode` (`E_BACKUP`, `E_API_DISABLED`, `E_FORBIDDEN`, and others), with a generic message for unknown codes.
- `Add\LetsEncryptDomain`: `mail` and `keyAlgo` arguments (`ecdsa-256`, `ecdsa-384` or `rsa`). `keyAlgo` is sent only when set, because HestiaCP 1.10.5 doesn't support it yet.
- `Add\User`: optional `name` and `lastname` arguments.
- `Delete\UserBackupExclusions`: optional `system` argument.
- Tests for the client and command processing, using Guzzle's `MockHandler`.
- GitHub Actions CI on PHP 8.2 to 8.5, plus a lowest-dependencies run on PHP 8.2.
- PHPStan (level 6) and a PHP-CS-Fixer coding-style check, run in CI. `composer check` runs them with the tests.

### Changed

- **BC break:** requires PHP 8.2 or later. PHP 8.1 reached end of life on 31 December 2025.
- **BC break:** list and detail methods return plain associative arrays instead of `Nette\Utils\ArrayHash`. Replace `$item->FIELD` with `$item['FIELD']`.
- **BC break:** exceptions moved from `neto737\HestiaCP\*` to `neto737\HestiaCP\Exceptions\*`, one class per file. Autoloading switched from `classmap` to PSR-4.
- **BC break:** TLS certificates are verified by default. For a self-signed certificate, pass `'verify' => false` or a CA bundle path.
- **BC break:** the hostname must include an `http://` or `https://` scheme. A port, path, query, fragment or user info in it throws `InvalidArgumentException`. A trailing slash is removed, and the scheme and host are lowercased.
- **BC break:** the 4th argument of `Webs::addDomainLetsEncrypt()` is renamed from `$restart` to `$mail`, which is how HestiaCP has always read it. Positional calls behave the same; named arguments must use the new name.
- **BC break:** `getTimeout()` is part of `ICommand`. Classes that implement `ICommand` directly must add it.
- Errors are read from HestiaCP's HTTP status and `Hestia-Exit-Code` header instead of Guzzle exceptions. Exit codes 9 and 10 throw `AuthorizationException`; other non-zero codes throw `ProcessException`; network and timeout failures throw `ClientException` with the original exception as `previous`.
- **BC break:** `Backups::backup()` and `Users::backup()` return `bool` instead of `string`. The backup scripts print a plain-text log, not JSON, so the old return value could not be parsed.
- `Databases::listDatabases()` returns every database instead of only the first one.
- `Add\User` sends a null package as `default`, so the arguments after it keep their positions.
- `Credentials` getters return `?string`.
- Guzzle requirement is `^7.15.2 || ^8.2`. PHPUnit is `^11.5 || ^12.0`.
- `minimum-stability` is `stable` instead of `dev`.
- Implicit nullable parameters (`string $x = null`) replaced with `?string`.
- Every file declares `strict_types=1`. Properties have native types instead of `@var` docblocks.
- **BC break:** `ICommand::process()` returns `mixed`. `ListCommand::process()` returns `array`. The setters in `Client`, `Credentials` and `Host` return `static`. `Module::$client` is typed `Client` and `ResponseCode::$messages` is typed `array`. Custom classes that implement or override these must declare compatible types.
- Documentation links point to `hestiacp.com/docs`.

### Removed

- **BC break:** `nette/utils` dependency.
- **BC break:** `ICommand::processException()` and `Command::processException()`, the unused `Command::throwCodeException()`, and the misspelled `ResponseCode::E_FORBIDEN` alias (use `E_FORBIDDEN`).
- VestaCP-era JSON workarounds in `Lists\MailDomainDkim` and `Lists\MailDomainDkimDns`. HestiaCP outputs valid JSON for both.
- Travis CI configuration.

### Fixed

- `TestAuthorization` sent an empty command, which current HestiaCP rejects. It now runs `v-list-sys-info` and returns `false` on an authentication failure.
- `Backup\User` and `Backup\Users` failed because they expected JSON. `Backup\Users` also sent a `json` argument the script doesn't take.
- PHP 8.1 deprecation warnings from passing `null` to `preg_match()` and `preg_replace()`.

## [1.2.0] - 2021-10-13

### Added

- Backup module (`Client::getModuleBackup()`): create, delete and list backups, and list and delete backup exclusions.
- `Users::backup()` to back up all users.

## [1.1.0] - 2021-09-10

### Added

- API key authentication: pass the key as the only credential to `Client::simpleFactory()` or `Credentials`.

## [1.0.1] - 2021-07-01

### Fixed

- `Unsuspend\MailAccount` called `v-suspend-mail-account` instead of `v-unsuspend-mail-account`.

## [1.0.0] - 2021-06-30

First release, with the user, web and mail modules.

[Unreleased]: https://github.com/neto737/HestiaCP-API/compare/v1.2.0...HEAD
[1.2.0]: https://github.com/neto737/HestiaCP-API/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/neto737/HestiaCP-API/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/neto737/HestiaCP-API/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/neto737/HestiaCP-API/releases/tag/v1.0.0
Loading
Loading