mirror of
https://github.com/envoyr/nginx-configurator.git
synced 2026-04-28 04:06:18 +00:00
add php 8.1 compability, remove console command
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
# for php-coveralls
|
|
||||||
coverage_clover: tests/coverage/clover.xml
|
|
||||||
json_path: tests/coverage/coveralls-upload.json
|
|
||||||
25
.travis.yml
25
.travis.yml
@@ -1,25 +0,0 @@
|
|||||||
language: php
|
|
||||||
|
|
||||||
php:
|
|
||||||
- 7.0
|
|
||||||
- nightly
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- php: hhvm
|
|
||||||
- php: nightly
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- composer self-update
|
|
||||||
|
|
||||||
install:
|
|
||||||
- composer install --prefer-dist --no-interaction
|
|
||||||
|
|
||||||
script:
|
|
||||||
- bin/phpspec run --format=pretty --no-code-generation
|
|
||||||
- bin/phpcov merge --clover tests/coverage/clover.xml tests/coverage
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- travis_retry php bin/coveralls -v
|
|
||||||
1
LICENSE
1
LICENSE
@@ -1,6 +1,7 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 Madkom S.A.
|
Copyright (c) 2016 Madkom S.A.
|
||||||
|
Copyright (c) 2022 envoyr <hello@envoyr.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -3,14 +3,7 @@ NGINX Configurator
|
|||||||
|
|
||||||
PHP Library for NGINX configuration parser/generator
|
PHP Library for NGINX configuration parser/generator
|
||||||
|
|
||||||

|

|
||||||
[](https://travis-ci.org/madkom/nginx-configurator)
|
|
||||||
[](https://packagist.org/packages/madkom/nginx-configurator)
|
|
||||||
[](https://packagist.org/packages/madkom/nginx-configurator)
|
|
||||||
[](https://packagist.org/packages/madkom/nginx-configurator)
|
|
||||||
[](https://coveralls.io/github/madkom/nginx-configurator?branch=master)
|
|
||||||
[](https://codeclimate.com/github/madkom/nginx-configurator)
|
|
||||||
[](https://codeclimate.com/github/madkom/nginx-configurator)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -25,12 +18,12 @@ In near future will provide CLI commands for NGINX configuration.
|
|||||||
Install with Composer
|
Install with Composer
|
||||||
|
|
||||||
```
|
```
|
||||||
composer require madkom/nginx-configurator
|
composer require envoyr/nginx-configurator
|
||||||
```
|
```
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
This library requires *PHP* in `~7` version.
|
This library requires *PHP* in `>=8.1` version.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -215,6 +208,7 @@ $builder->dumpFile('generated.conf');
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 Madkom S.A.
|
Copyright (c) 2016 Madkom S.A.
|
||||||
|
Copyright (c) 2022 envoyr <hello@envoyr.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
namespace Madkom\NginxConfigurator;
|
namespace Envoyr\NginxConfigurator;
|
||||||
|
|
||||||
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
||||||
// Called from local git clone.
|
// Called from local git clone.
|
||||||
|
|||||||
21
build.xml
21
build.xml
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<project name="nginx-configurator" default="test">
|
|
||||||
<target name="test" depends="-lint,-phpspec,-phpunit,-phpcs">
|
|
||||||
<exec command="bin/phpcov merge --clover tests/coverage/clover.xml tests/coverage/" checkreturn="true" passthru="true"/>
|
|
||||||
<exec command="bin/coveralls" checkreturn="true" passthru="true"/>
|
|
||||||
<exec command="bin/clover-dump --warning-percentage=70 --error-percentage=50 --fail-at=40 --ansi tests/coverage/clover.xml" checkreturn="true" passthru="true"/>
|
|
||||||
<exec command="bin/phpcov merge --html=tests/coverage/raport tests/coverage/"/>
|
|
||||||
</target>
|
|
||||||
<target name="-lint" hidden="true">
|
|
||||||
<exec command="bin/parallel-lint --exclude app --exclude vendor ." checkreturn="true" passthru="true"/>
|
|
||||||
</target>
|
|
||||||
<target name="-phpunit" hidden="true">
|
|
||||||
<exec command="bin/phpunit --coverage-php tests/coverage/phpunit.cov tests" checkreturn="true" passthru="true"/>
|
|
||||||
</target>
|
|
||||||
<target name="-phpspec" hidden="true">
|
|
||||||
<exec command="bin/phpspec run --format=pretty --no-code-generation" checkreturn="true" passthru="true"/>
|
|
||||||
</target>
|
|
||||||
<target name="-phpcs" hidden="true">
|
|
||||||
<exec command="bin/phpcs --colors -wp src --report=summary --standard=PSR2,phpcs.xml" checkreturn="true" passthru="true"/>
|
|
||||||
</target>
|
|
||||||
</project>
|
|
||||||
@@ -1,38 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "madkom/nginx-configurator",
|
"name": "envoyr/nginx-configurator",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "http://madkom.pl/",
|
"homepage": "https://envoyr.com/",
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"require": {
|
"require": {
|
||||||
"madkom/collection": "1.*",
|
"envoyr/collection": "dev-main",
|
||||||
"ferno/loco": "@dev",
|
"envoyr/loco": "dev-main"
|
||||||
"madkom/uri": "1.*"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {},
|
||||||
"henrikbjorn/phpspec-code-coverage": "^2.0.2",
|
|
||||||
"phpspec/phpspec": "^2.5",
|
|
||||||
"phpunit/phpunit": "~4",
|
|
||||||
"knplabs/phpspec-welldone-extension": "dev-master",
|
|
||||||
"squizlabs/php_codesniffer": "^2.3",
|
|
||||||
"phpunit/phpcov": "*",
|
|
||||||
"jakub-onderka/php-parallel-lint": "0.*",
|
|
||||||
"jakub-onderka/php-console-highlighter": "0.*",
|
|
||||||
"satooshi/php-coveralls": "dev-master",
|
|
||||||
"clover/dump": "dev-master",
|
|
||||||
"symfony/var-dumper": "^3.1"
|
|
||||||
},
|
|
||||||
"repositories": [
|
|
||||||
{
|
|
||||||
"type": "vcs",
|
|
||||||
"url": "git@github.com:madkom/loco.git"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Madkom\\NginxConfigurator\\": "src/"
|
"Envoyr\\NginxConfigurator\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "envoyr",
|
||||||
|
"email": "hello@envoyr.com"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Michał Brzuchalski",
|
"name": "Michał Brzuchalski",
|
||||||
"email": "m.brzuchalski@madkom.pl"
|
"email": "m.brzuchalski@madkom.pl"
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
|
|
||||||
use Madkom\NginxConfigurator\Builder;
|
use Madkom\NginxConfigurator\Builder;
|
||||||
use Madkom\NginxConfigurator\Config\Location;
|
use Madkom\NginxConfigurator\Config\Location;
|
||||||
|
use Madkom\NginxConfigurator\Factory;
|
||||||
use Madkom\NginxConfigurator\Node\Directive;
|
use Madkom\NginxConfigurator\Node\Directive;
|
||||||
use Madkom\NginxConfigurator\Node\Literal;
|
use Madkom\NginxConfigurator\Node\Literal;
|
||||||
use Madkom\NginxConfigurator\Node\Param;
|
use Madkom\NginxConfigurator\Node\Param;
|
||||||
|
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
$factory = new Factory();
|
||||||
$builder = new Builder();
|
$builder = new Builder();
|
||||||
|
|
||||||
$server = $builder->addServerNode(80);
|
$server = $builder->append($factory->createServer(80));
|
||||||
$server->append(new Directive('error_log', [new Param('/var/log/nginx/error.log'), new Param('debug')]));
|
$server->append(new Directive('error_log', [new Param('/var/log/nginx/error.log'), new Param('debug')]));
|
||||||
$server->append(new Location(new Param('/test'), null, [
|
$server->append(new Location(new Param('/test'), null, [
|
||||||
new Directive('error_page', [new Param('401'), new Param('@unauthorized')]),
|
new Directive('error_page', [new Param('401'), new Param('@unauthorized')]),
|
||||||
|
|||||||
11
phpcs.xml
11
phpcs.xml
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ruleset name="Selective Standard">
|
|
||||||
<description>Project Coding Standard</description>
|
|
||||||
<file>./src</file>
|
|
||||||
<rule ref="Generic.Files.LineLength">
|
|
||||||
<properties>
|
|
||||||
<property phpcs-only="true" name="lineLimit" value="130"/>
|
|
||||||
<property phpcbf-only="true" name="lineLimit" value="150"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
</ruleset>
|
|
||||||
15
phpspec.yml
15
phpspec.yml
@@ -1,15 +0,0 @@
|
|||||||
extensions:
|
|
||||||
- PhpSpec\Extension\CodeCoverageExtension
|
|
||||||
- Knp\PhpSpec\WellDone\Extension
|
|
||||||
|
|
||||||
suites:
|
|
||||||
types:
|
|
||||||
namespace: Madkom\NginxConfigurator
|
|
||||||
psr4_prefix: Madkom\NginxConfigurator
|
|
||||||
spec_path: tests
|
|
||||||
|
|
||||||
code_coverage:
|
|
||||||
output: tests/coverage/phpspec.cov
|
|
||||||
format: php
|
|
||||||
|
|
||||||
formatter.name: pretty
|
|
||||||
27
phpunit.xml
27
phpunit.xml
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
|
||||||
backupGlobals="false"
|
|
||||||
colors="true"
|
|
||||||
>
|
|
||||||
<testsuites>
|
|
||||||
<testsuite name="Application Test Suite">
|
|
||||||
<directory suffix="Test.php">./tests/phpunit/</directory>
|
|
||||||
<exclude>./vendor</exclude>
|
|
||||||
<exclude>./app</exclude>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
<filter>
|
|
||||||
<blacklist>
|
|
||||||
<directory suffix=".php">./vendor</directory>
|
|
||||||
<directory suffix=".php">./app</directory>
|
|
||||||
<directory suffix=".php">./bin</directory>
|
|
||||||
<directory suffix=".php">./tests</directory>
|
|
||||||
<file>./var/bootstrap.php.cache</file>
|
|
||||||
</blacklist>
|
|
||||||
</filter>
|
|
||||||
<php>
|
|
||||||
<server name="KERNEL_DIR" value="./app/" />
|
|
||||||
</php>
|
|
||||||
|
|
||||||
</phpunit>
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 18.04.16
|
* Date: 18.04.16
|
||||||
* Time: 11:06
|
* Time: 11:06
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator;
|
namespace Envoyr\NginxConfigurator;
|
||||||
|
|
||||||
use Countable;
|
use Countable;
|
||||||
use Madkom\Collection\CustomTypedCollection;
|
use Madkom\Collection\CustomTypedCollection;
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 14:25
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AddLocationCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class AddLocationCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('location:add');
|
|
||||||
$this->setDescription("Adds location context and configuration");
|
|
||||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Server hostname:port', 'localhost:80');
|
|
||||||
$this->addOption('internal', null, InputOption::VALUE_NONE, 'Adds internal directive');
|
|
||||||
$this->addOption(
|
|
||||||
'proxy_pass',
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'Adds proxy_pass url <comment>(eg. http://proxy/)</comment>'
|
|
||||||
);
|
|
||||||
$this->addOption(
|
|
||||||
'proxy_bind',
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'Adds proxy_bind directive url or variable <comment>(eg. $server_addr)</comment>'
|
|
||||||
);
|
|
||||||
$this->addOption(
|
|
||||||
'proxy_redirect',
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_OPTIONAL ^ InputOption::VALUE_IS_ARRAY,
|
|
||||||
'Adds proxy_redirect directive <comment>(eg. http://$host or https://$host)</comment>'
|
|
||||||
);
|
|
||||||
$this->addOption(
|
|
||||||
'proxy_set_header',
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_OPTIONAL ^ InputOption::VALUE_IS_ARRAY,
|
|
||||||
'Adds proxy_set_header directive <comment>(eg. "Content-Type: text/html"</comment>'
|
|
||||||
);
|
|
||||||
$this->addOption(
|
|
||||||
'proxy_pass_request_body',
|
|
||||||
null,
|
|
||||||
InputOption::VALUE_OPTIONAL,
|
|
||||||
'Adds proxy_pass_requeest_body directive <comment>(on|off)</comment>',
|
|
||||||
'on'
|
|
||||||
);
|
|
||||||
|
|
||||||
// // new Directive('internal'),
|
|
||||||
// new Directive('expires', [new Param('-1')]),
|
|
||||||
// new Directive('proxy_pass', [new Param('http://172.17.0.1:7777')]),
|
|
||||||
// new Directive('proxy_bind', [new Param('$server_addr')]),
|
|
||||||
// new Directive('proxy_redirect', [new Param('http://$host'), new Param('https://$host')]),
|
|
||||||
// new Directive('proxy_set_header', [new Param('Content-Length'), new Literal("")]),
|
|
||||||
// new Directive('proxy_pass_request_body', [new Param('off')]),
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
|
||||||
{
|
|
||||||
|
|
||||||
$proxy_pass = $input->getOption('proxy_pass');
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 13:38
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Builder;
|
|
||||||
use Madkom\NginxConfigurator\Config\Server;
|
|
||||||
use Madkom\NginxConfigurator\Node\Directive;
|
|
||||||
use Madkom\NginxConfigurator\Node\Param;
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AddServerCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class AddServerCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('server:add');
|
|
||||||
$this->setDescription("Adds server context and configuration of port and name");
|
|
||||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Server hostname:port', 'localhost:80');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
|
||||||
{
|
|
||||||
$filename = $input->getOption('file');
|
|
||||||
$config = $this->getConfig($input);
|
|
||||||
|
|
||||||
list($name, $port) = explode(':', $input->getArgument('name') . ':80');
|
|
||||||
|
|
||||||
$listenIPv4 = new Directive('listen', [new Param($port)]);
|
|
||||||
$listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), new Param('default'), new Param('ipv6only=on')]);
|
|
||||||
|
|
||||||
// TODO: Find server by name
|
|
||||||
$server = new Server([$listenIPv4, $listenIPv6]);
|
|
||||||
if ($name != 'localhost' && !empty($name)) {
|
|
||||||
$server->append(new Directive('server_name', [new Param($name)]));
|
|
||||||
}
|
|
||||||
$config->append($server);
|
|
||||||
|
|
||||||
$builder = new Builder();
|
|
||||||
$builder->append($server);
|
|
||||||
$builder->dumpFile($filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 14:25
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AddUpstreamCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class AddUpstreamCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('upstream:add');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 14:31
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AddUpstreamServerCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class AddUpstreamServerCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('upstream:server:add');
|
|
||||||
$this->setDescription("Adds server directive to upstream context and configuration");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 14:01
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Madkom\NginxConfigurator\Builder;
|
|
||||||
use Madkom\NginxConfigurator\Node\Node;
|
|
||||||
use Madkom\NginxConfigurator\Node\RootNode;
|
|
||||||
use Madkom\NginxConfigurator\Parser;
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class BaseCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
abstract class BaseCommand extends Command
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this->addOption('file', 'f', InputOption::VALUE_OPTIONAL, 'Output filename', 'php://stdout');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param InputInterface $input
|
|
||||||
* @return RootNode
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
protected function getConfig(InputInterface $input) : RootNode
|
|
||||||
{
|
|
||||||
$filename = $input->getOption('file');
|
|
||||||
if ($filename != 'php://stdout' && !file_exists($filename)) {
|
|
||||||
@touch($filename);
|
|
||||||
}
|
|
||||||
if ($filename != 'php://stdout' && file_exists($filename)) {
|
|
||||||
if (!is_writable($filename)) {
|
|
||||||
throw new Exception('Given filename is not writable!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($filename != 'php://stdout' && file_exists($filename)) {
|
|
||||||
$parser = new Parser();
|
|
||||||
return $parser->parseFile($filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RootNode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 14:25
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class RemoveLocationCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class RemoveLocationCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('location:remove');
|
|
||||||
$this->setDescription("Remove location context and it's configuration");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 13:38
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Builder;
|
|
||||||
use Madkom\NginxConfigurator\Config\Server;
|
|
||||||
use Madkom\NginxConfigurator\Node\Directive;
|
|
||||||
use Madkom\NginxConfigurator\Node\Param;
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class RemoveServerCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class RemoveServerCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('server:remove');
|
|
||||||
$this->setDescription("Removes server context and it's configuration");
|
|
||||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Server hostname:port', 'localhost:80');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
|
||||||
{
|
|
||||||
$filename = $input->getOption('file');
|
|
||||||
$builder = $this->getConfig($input);
|
|
||||||
|
|
||||||
list($name, $port) = explode(':', $input->getArgument('name') . ':80');
|
|
||||||
|
|
||||||
$listenIPv4 = new Directive('listen', [new Param($port)]);
|
|
||||||
$listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), new Param('default'), new Param('ipv6only=on')]);
|
|
||||||
|
|
||||||
$server = new Server([$listenIPv4, $listenIPv6]);
|
|
||||||
if ($name != 'localhost' && !empty($name)) {
|
|
||||||
$server->append(new Directive('server_name', [new Param($name)]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$builder->appendServerNode($server);
|
|
||||||
$builder->dumpFile($filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 14:25
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class RemoveUpstreamCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class RemoveUpstreamCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('upstream:remove');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: mbrzuchalski
|
|
||||||
* Date: 10.06.16
|
|
||||||
* Time: 14:31
|
|
||||||
*/
|
|
||||||
namespace Madkom\NginxConfigurator\Command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class RemoveUpstreamServerCommand
|
|
||||||
* @package Madkom\NginxConfigurator\Command
|
|
||||||
* @author Michał Brzuchalski <m.brzuchalski@madkom.pl>
|
|
||||||
*/
|
|
||||||
class RemoveUpstreamServerCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
parent::configure();
|
|
||||||
$this->setName('upstream:server:remove');
|
|
||||||
$this->setDescription("Removes server directive from upstream context and configuration");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 20:55
|
* Time: 20:55
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Config;
|
namespace Envoyr\NginxConfigurator\Config;
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Node\Context;
|
use Madkom\NginxConfigurator\Node\Context;
|
||||||
use Madkom\NginxConfigurator\Node\Directive;
|
use Madkom\NginxConfigurator\Node\Directive;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 20:57
|
* Time: 20:57
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Config;
|
namespace Envoyr\NginxConfigurator\Config;
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Node\Context;
|
use Madkom\NginxConfigurator\Node\Context;
|
||||||
use Madkom\NginxConfigurator\Node\Directive;
|
use Madkom\NginxConfigurator\Node\Directive;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 21:01
|
* Time: 21:01
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Config;
|
namespace Envoyr\NginxConfigurator\Config;
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Node\Context;
|
use Madkom\NginxConfigurator\Node\Context;
|
||||||
use Madkom\NginxConfigurator\Node\Literal;
|
use Madkom\NginxConfigurator\Node\Literal;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 21:00
|
* Time: 21:00
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Config;
|
namespace Envoyr\NginxConfigurator\Config;
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Node\Context;
|
use Madkom\NginxConfigurator\Node\Context;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 21:07
|
* Time: 21:07
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Config;
|
namespace Envoyr\NginxConfigurator\Config;
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Node\Context;
|
use Madkom\NginxConfigurator\Node\Context;
|
||||||
use Madkom\NginxConfigurator\Node\Directive;
|
use Madkom\NginxConfigurator\Node\Directive;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 10.04.16
|
* Date: 10.04.16
|
||||||
* Time: 09:12
|
* Time: 09:12
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Exception;
|
namespace Envoyr\NginxConfigurator\Exception;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 13.04.16
|
* Date: 13.04.16
|
||||||
* Time: 09:22
|
* Time: 09:22
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Exception;
|
namespace Envoyr\NginxConfigurator\Exception;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 14.06.16
|
* Date: 14.06.16
|
||||||
* Time: 11:22
|
* Time: 11:22
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator;
|
namespace Envoyr\NginxConfigurator;
|
||||||
|
|
||||||
use Madkom\NginxConfigurator\Config\Location;
|
use Madkom\NginxConfigurator\Config\Location;
|
||||||
use Madkom\NginxConfigurator\Config\Server;
|
use Madkom\NginxConfigurator\Config\Server;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 20:53
|
* Time: 20:53
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Node;
|
namespace Envoyr\NginxConfigurator\Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Context
|
* Class Context
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 06.04.16
|
* Date: 06.04.16
|
||||||
* Time: 13:40
|
* Time: 13:40
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Node;
|
namespace Envoyr\NginxConfigurator\Node;
|
||||||
|
|
||||||
use Madkom\Collection\CustomTypedCollection;
|
use Madkom\Collection\CustomTypedCollection;
|
||||||
use Traversable;
|
use Traversable;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 10:32
|
* Time: 10:32
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Node;
|
namespace Envoyr\NginxConfigurator\Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Literal
|
* Class Literal
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 06.04.16
|
* Date: 06.04.16
|
||||||
* Time: 13:23
|
* Time: 13:23
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Node;
|
namespace Envoyr\NginxConfigurator\Node;
|
||||||
|
|
||||||
use Countable;
|
use Countable;
|
||||||
use IteratorAggregate;
|
use IteratorAggregate;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 10:31
|
* Time: 10:31
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Node;
|
namespace Envoyr\NginxConfigurator\Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Param
|
* Class Param
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 08.04.16
|
* Date: 08.04.16
|
||||||
* Time: 21:18
|
* Time: 21:18
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator\Node;
|
namespace Envoyr\NginxConfigurator\Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RootNode
|
* Class RootNode
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 06.04.16
|
* Date: 06.04.16
|
||||||
* Time: 13:01
|
* Time: 13:01
|
||||||
*/
|
*/
|
||||||
namespace Madkom\NginxConfigurator;
|
namespace Envoyr\NginxConfigurator;
|
||||||
|
|
||||||
use Ferno\Loco\ConcParser;
|
use Ferno\Loco\ConcParser;
|
||||||
use Ferno\Loco\Grammar;
|
use Ferno\Loco\Grammar;
|
||||||
|
|||||||
Reference in New Issue
Block a user