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

Commit 5f60799

Browse files
Add setAccessLog method
1 parent 545cf2e commit 5f60799

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Interfaces/UnitInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ public function getConfig(): ConfigInterface;
1313
public function getStatistics(): StatisticsInterface;
1414

1515
public function getCertificates(): array;
16+
17+
public function setAccessLog($path, $format = null);
1618
}

src/Unit.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Pavlusha311245\UnitPhpSdk;
44

55
use Pavlusha311245\UnitPhpSdk\Config\Statistic;
6+
use Pavlusha311245\UnitPhpSdk\Enums\HttpMethodsEnum;
67
use Pavlusha311245\UnitPhpSdk\Exceptions\UnitException;
78
use Pavlusha311245\UnitPhpSdk\Interfaces\UnitInterface;
89

@@ -99,4 +100,27 @@ public function getStatistics(): Interfaces\StatisticsInterface
99100

100101
return new Statistic($result);
101102
}
103+
104+
/**
105+
* Setup access log file
106+
*
107+
* @return void
108+
* @throws UnitException
109+
*/
110+
public function setAccessLog($path, $format = null)
111+
{
112+
$data['path'] = $path;
113+
114+
if (!empty($format)) {
115+
$data['format'] = $format;
116+
}
117+
118+
$request = new UnitRequest($this->socket, $this->address);
119+
$request->setMethod(HttpMethodsEnum::PUT->value);
120+
$request->setData(json_encode($data));
121+
122+
return $request->send('/config/access_log');
123+
// TODO: Implement setApplicationLogPath() method.
124+
// Implement functions from this source https://unit.nginx.org/configuration/#access-log
125+
}
102126
}

0 commit comments

Comments
 (0)