2 Commits
1.0.0 ... 1.2.0

Author SHA1 Message Date
eeb85df689 Add additional parameters to createServer method 2025-11-10 01:45:09 +01:00
a66ae2c266 add raw nodes 2025-01-04 16:40:48 +01:00
2 changed files with 53 additions and 3 deletions

49
src/Config/Raw.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
/**
* Created by PhpStorm.
* User: envoyr
* Date: 04.01.25
* Time: 16:29
*/
namespace Envoyr\NginxConfigurator\Config;
use Envoyr\NginxConfigurator\Node\Context;
use Envoyr\NginxConfigurator\Node\Literal;
use Envoyr\NginxConfigurator\Node\Node;
use Envoyr\NginxConfigurator\Node\Param;
/**
* Class Raw
* @package Envoyr\NginxConfigurator\Config
* @author Maurice Preuß <hello@envoyr.com>
*/
class Raw extends Node
{
/**
* Holds raw string
* @var string
*/
private $raw;
/**
* Raw constructor.
* @param string $raw
*/
public function __construct(string $raw)
{
$this->raw = $raw;
}
public function __toString() : string
{
return $this->raw;
}
/**
* @return string
*/
public function getRaw() : string
{
return (string)$this->raw;
}
}

View File

@@ -16,12 +16,13 @@ class Factory
/**
* Creates Server node
* @param int $port
* @param array $additionalParams
* @return Server
*/
public function createServer(int $port = 80) : Server
public function createServer(int $port = 80, array $additionalParams = []) : Server
{
$listenIPv4 = new Directive('listen', [new Param($port)]);
$listenIPv6 = new Directive('listen', [new Param("[::]:{$port}")]);
$listenIPv4 = new Directive('listen', [new Param($port), ...$additionalParams]);
$listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), ...$additionalParams]);
return new Server([$listenIPv4, $listenIPv6]);
}