PHP code example of romanpitak / nginx-config-processor

1. Go to this page and download the library: Download romanpitak/nginx-config-processor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

romanpitak / nginx-config-processor example snippets


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


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');

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


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

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

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