Coder Social home page Coder Social logo

nginx-config-processor's Introduction

Nginx Configuration Processor

Latest Stable Version Total Downloads License Build Status Code Climate Test Coverage Codacy Badge Codacy Badge

(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 romanpitak/nginx-config-processor

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;

nginx-config-processor's People

Contributors

romanpitak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nginx-config-processor's Issues

Short scopes on one line

Printing the short (one directive) scopes on the same line as the directive that contains them.

Multiple comments per directive

Allow the Directive to store multiple assigned comments:

  • the "Above Directive Comment" or comment block
  • the "In-line Comment"
  • the "End of Scope Comment"
    And implement the correct printing of the comments with appropriate printing rules.

prettyPrint(0) is adding indent

It's mostly a question, not a bug... why prettyPrint(0) adding indent to each line?

I'm adding prettyPrint(-1) to avoid this behavior.

Update config

Is there is a way to update directives values or append directives to existing ones?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.