Skip to content

PHP Nginx configuration files processor (parser, creator, generator).

License

Notifications You must be signed in to change notification settings

tomsseisums/nfigurator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nfigurator

NGINX Configuration Processor

(c) 2017 Toms Seisums
(c) 2014-2016 Roman Piták [email protected]

PHP Nginx configuration files processor (parser, creator).

Installation

The best way to install is to use the Composer dependency manager.

php composer.phar require joltmode/nfigurator

Features

Pretty Print

<?php Scope::fromFile('m1.conf')->saveToFile('out.conf');

Config Create

<?php
Scope::create()
    ->addDirective(Directive::create('server')
        ->setChildScope(Scope::create()
            ->addDirective(Directive::create('listen', 8080))
            ->addDirective(Directive::create('server_name', 'example.net'))
            ->addDirective(Directive::create('root', 'C:/www/example_net'))
            ->addDirective(Directive::create('location', '^~ /var/', Scope::create()
                    ->addDirective(Directive::create('deny', 'all'))
                )->setCommentText('Deny access for location /var/')
            )
        )
    )
    ->saveToFile('example.net');

File example.net:

server {
    listen 8080;
    server_name example.net;
    root C:/www/example_net;
    location ^~ /var/ { # Deny access for location /var/
        deny all;
    }
}

Comments handling

Simple comments

<?php echo new Comment("This is a simple comment.");

output:

# This is a simple comment.

Multi-line comments

<?php
echo new Comment("This \nis \r\na multi
line " . PHP_EOL . "comment.");

output:

# This
# is
# a multi
# line
# comment.

Directive with a simple comment

<?php echo Directive::create('deny', 'all')->setCommentText('Directive with a comment');

output:

deny all; # Directive with a comment

Directive with a multi-line comment

<?php echo Directive::create('deny', 'all')->setCommentText('Directive
with a multi line comment');

output:

# Directive
# with a multi line comment
deny all;

About

PHP Nginx configuration files processor (parser, creator, generator).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 99.0%
  • Makefile 1.0%