<commit_before>ngx_php7
========
[![Build Status](https://travis-ci.org/rryqszq4/ngx_php7.svg?branch=master)](https://travis-ci.org/rryqszq4/ngx_php7)
[![GitHub release](https://img.shields.io/github/release/rryqszq4/ngx_php7.svg)](https://github.com/rryqszq4/ngx_php7/releases/latest)
[![license](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg)](https://github.com/rryqszq4/ngx_php7/blob/master/LICENSE)
[![QQ group](https://img.shields.io/badge/QQ--group-558795330-26bcf5.svg)](https://github.com/rryqszq4/ngx_php7)

![](https://raw.githubusercontent.com/rryqszq4/ngx_php7/master/docs/hello_world_performance.png)

ngx_php7 is an extension module of high-performance web server nginx, which implements embedded php7 script to process nginx location and variables.  

ngx_php7 draws on the design of [ngx_lua](https://github.com/openresty/lua-nginx-module) and is committed to providing non-blocking web services with significant performance advantages over php-cgi, mod_php, php-fpm and hhvm.  

ngx_php7 doesn't want to replace anything, just want to provide a solution.  

There is a legacy version of [ngx_php5](https://github.com/rryqszq4/ngx_php/tree/ngx_php5), which records some of my past code practices and is also valuable.   

[Benchmarks about ngx_php7 and php](https://www.techempower.com/benchmarks/#section=test&runid=76a34044-54d6-4349-adfe-863c2d5ae756&hw=ph&test=plaintext&l=zik073-7)  

What's different with official php
----------------------------------
* Global variable is unsafe in per request
* Static variable of a class is unsafe in per request
* Do not design singleton mode
* The native IO function works fine, but it slows down nginx

Requirement
-----------
- PHP-7.0.* ~ PHP-7.3.*
- nginx-1.4.7 ~ nginx-1.14.2 and mainline 1.15.7

Installation
------------

### Compile install

```sh
$ wget 'http://php.net/distributions/php-7.2.14.tar.gz'
$ tar xf php-7.2.14.tar.gz
$ cd php-7.2.14

$ ./configure --prefix=/path/to/php --enable-embed
$ make && make install

$ git clone https://github.com/rryqszq4/ngx_php7.git

$ wget 'http://nginx.org/download/nginx-1.12.2.tar.gz'
$ tar -zxvf nginx-1.12.2.tar.gz
$ cd nginx-1.12.2

$ export PHP_CONFIG=/path/to/php/bin/php-config
$ export PHP_BIN=/path/to/php/bin
$ export PHP_INC=/path/to/php/include/php
$ export PHP_LIB=/path/to/php/lib

$ ./configure --user=www --group=www \
$             --prefix=/path/to/nginx \
$             --with-ld-opt="-Wl,-rpath,$PHP_LIB" \
$             --add-module=/path/to/ngx_php7/third_party/ngx_devel_kit \
$             --add-module=/path/to/ngx_php7
$ make && make install
```

### CentOS / RedHat 7

```sh
yum -y install https://extras.getpagespeed.com/release-el7-latest.rpm
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
yum-config-manager --enable remi-php73
yum install nginx-module-php7
```

Edit `nginx.conf` and load the required modules at the top:

    load_module modules/ndk_http_module.so;
    load_module modules/ngx_http_php_module.so;

### Docker

```sh
$ docker build -t nginx-php7 .
$ : "app.conf: Create nginx config"
$ docker run -p 80:80 -v $PWD/app.conf:/etc/nginx/conf.d/default.conf nginx-php7
```


Synopsis
--------

```nginx
user www www;
worker_processes  4;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;
    
    client_max_body_size 64k;   
    client_body_buffer_size 64k;

    php_ini_path /usr/local/php/etc/php.ini;

    server {
        listen       80;
        server_name  localhost;
        default_type 'application/json; charset=UTF-8';
    
        location /php {
            content_by_php '
                echo "hello ngx_php7";
            ';
        }

        location = /ngx_request {
            content_by_php '
                echo ngx_request::document_uri();
            ';
        }

        # curl /ngx_get?a=1&b=2
        location = /ngx_get {
            content_by_php '
                echo "ngx::query_args()\n";
                var_dump(ngx::query_args());
            ';
        }

        # curl -d 'a=1&b=2' /ngx_post
        location = /ngx_post {
            content_by_php '
                echo "ngx::post_args()\n";
                var_dump(ngx::post_args());
            ';
        }

        location = /ngx_sleep {
            content_by_php '
                echo "ngx_sleep start\n";
                yield ngx::sleep(1);
                echo "ngx_sleep end\n";
            ';
        }

        location = /ngx_socket2 {
            default_type 'application/json;charset=UTF-8';
            content_by_php '
                $fd = ngx_socket_create();
                var_dump($fd);
                yield ngx_socket_connect($fd, "hq.sinajs.cn", 80);
                $send_buf = "GET /list=s_sh000001 HTTP/1.0\r\n
                                            Host: hq.sinajs.cn\r\nConnection: close\r\n\r\n";
                yield ngx_socket_send($fd, $send_buf, strlen($send_buf));
                $recv_buf = "";
                yield ngx_socket_recv($fd, $recv_buf);
                var_dump($recv_buf);
                yield ngx_socket_close($fd);
            ';
        }

        location = /ngx_var {
            set $a 1234567890;
            content_by_php '
                $a = ngx_var::get("a");
                var_dump($a);
            ';
        }
        
        # set content-type of response headers
        location = /ngx_header {
            content_by_php '
                ngx_header_set("Content-Type", "text/html; charset=UTF-8");
            ';
        }

        # run a php file
        location = /php {
            content_by_php '
                include "name_of_php_file.php";
            ';
        }
        
        # run any php file in root
        location = / {
            content_by_php '
                include ngx_var::get("uri");
            ';
        }

    }
}
```

Test
----
Using the perl of [Test::Nginx](https://github.com/openresty/test-nginx) module to testing, searching and finding out problem in ngx_php7.
```sh
ngx_php7 test ...
nginx version: nginx/1.10.3
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 
configure arguments: --prefix=/home/travis/build/rryqszq4/ngx_php7/build/nginx --with-ld-opt=-Wl,-rpath,/home/travis/build/rryqszq4/ngx_php7/build/php/lib --add-module=../../../ngx_php7/third_party/ngx_devel_kit --add-module=../../../ngx_php7
t/001-hello.t ........... ok
t/002-ini.t ............. ok
t/004-ngx_request.t ..... ok
t/005-ngx_log.t ......... ok
t/006-ngx_sleep.t ....... ok
t/007-ngx_socket.t ...... ok
t/008-ngx_exit.t ........ ok
t/009-ngx_query_args.t .. ok
t/010-ngx_post_args.t ... ok
t/011-ngx_constants.t ... ok
t/012-function.t ........ ok
t/013-class.t ........... ok
t/014-ngx_var.t ......... ok
All tests successful.
Files=13, Tests=28,  5 wallclock secs ( 0.05 usr  0.02 sys +  1.26 cusr  0.22 csys =  1.55 CPU)
Result: PASS
```

Directives
----------
* [php_ini_path](#php_ini_path)
* [init_worker_by_php](#init_worker_by_php)
* [rewrite_by_php](#rewrite_by_php)
* [access_by_php](#access_by_php)
* [content_by_php](#content_by_php)
* [log_by_php](#log_by_php)
* [header_filter_by_php](#header_filter_by_php)
* [body_filter_by_php](#body_filter_by_php)

php_ini_path
------------
* **syntax:** `php_ini_path`_`<php.ini file path>`_
* **context:** `http`
* **phase:** `loading-config`

init_worker_by_php
------------------
* **syntax:** `init_worker_by_php`_`<php script code>`_
* **context:** `http`
* **phase:** `starting-worker`

rewrite_by_php
--------------
* **syntax:** `rewrite_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `rewrite`

access_by_php
-------------
* **syntax:** `access_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `access`

content_by_php
--------------
* **syntax:** `content_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `content`

log_by_php
----------
* **syntax:** `log_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `log`

header_filter_by_php
--------------------
* **syntax:** `header_filter_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `output-header-filter`

body_filter_by_php
------------------
* **syntax:** `body_filter_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `output-body-filter`


Nginx API for php
-----------------
* [ngx_exit](#ngx_exit)
* [ngx_query_args](#ngx_query_args)
* [ngx_post_args](#ngx_post_args)
* [ngx_log_error](#ngx_log_error)
* [ngx_request_method](#ngx_request_method)
* [ngx_request_document_root](#ngx_request_document_root)
* [ngx_request_document_uri](#ngx_request_document_uri)
* [ngx_request_script_name](#ngx_request_script_name)
* [ngx_request_script_filename](#ngx_request_script_filename)
* [ngx_request_query_string](#ngx_request_query_string)
* [ngx_request_uri](#ngx_request_uri)
* [ngx_request_server_protocol](#ngx_request_server_protocol)
* [ngx_request_remote_addr](#ngx_request_remote_addr)
* [ngx_request_server_addr](#ngx_request_server_addr)
* [ngx_request_remote_port](#ngx_request_remote_port)
* [ngx_request_server_port](#ngx_request_server_port)
* [ngx_request_server_name](#ngx_request_server_name)
* [ngx_request_headers](#ngx_request_headers)
* [ngx_var_get](#ngx_var_get)
* [ngx_var_set](#ngx_var_set)
* [ngx_header_set](#ngx_header_set)
* [ngx_header_get](#ngx_header_get)
* [ngx_header_gets](#ngx_header_gets)
* [ngx_redirect](#ngx_redirect)

ngx_exit
--------
* **syntax:** `void ngx_exit(int $status)`

ngx_query_args
--------------
* **syntax:** `array ngx_query_args(void)` or `array ngx::query_args(void)`

ngx_post_args
-------------
* **syntax:** `array ngx_post_args(void)` or `array ngx::post_args(void)`

ngx_log_error
-------------
* **syntax:** `void ngx_log_error(int $level, string $log_str)` or `void ngx_log::error(int $level, string $log_str)`

ngx_request_method
------------------
* **syntax:** `string ngx_request_method(void)` or `string ngx_request::method(void)`

ngx_request_document_root
-------------------------
* **syntax:** `string ngx_request_document_root(void)` or `string ngx_request::document_root(void)`

ngx_request_document_uri
------------------------
* **syntax:** `string ngx_request_document_uri(void)` or `string ngx_request::document_uri(void)`

ngx_request_script_name
-----------------------
* **syntax:** `string ngx_request_script_name(void)` or `string ngx_request::script_name(void)`

ngx_request_script_filename
---------------------------
* **syntax:** `string ngx_request_script_filename(void)` or `string ngx_request::script_filename(void)`

ngx_request_query_string
------------------------
* **syntax:** `string ngx_request_query_string(void)` or `string ngx_request::query_string(void)`

ngx_request_uri
---------------
* **syntax:** `string ngx_request_uri(void)` or `string ngx_request::uri(void)`

ngx_request_server_protocol
---------------------------
* **syntax:** `string ngx_request_server_protocol(void)` or `string ngx_request::server_protocol(void)`

ngx_request_remote_addr
-----------------------
* **syntax:** `string ngx_request_remote_addr(void)` or `string ngx_request::remote_addr(void)`

ngx_request_server_addr
-----------------------
* **syntax:** `string ngx_request_server_addr(void)` or `string ngx_request::server_addr(void)`

ngx_request_remote_port
-----------------------
* **syntax:** `int ngx_request_remote_port(void)` or `int ngx_request::remote_port(void)`

ngx_request_server_port
-----------------------
* **syntax:** `int ngx_request_server_port(void)` or `int ngx_request::server_port(void)`

ngx_request_server_name
-----------------------
* **syntax:** `string ngx_request_server_name(void)` or `string ngx_request::server_name(void)`

ngx_request_headers
-------------------
* **syntax:** `array ngx_request_headers(void)` or `array ngx_request::headers(void)`

ngx_var_get
-----------
* **syntax:** `string ngx_var_get(string $key)` or `string ngx_var::get(string $key)`

ngx_var_set
-----------
* **syntax:** `void ngx_var_set(string $key, string $value)` or `void ngx_var::set(string $key, string $value)`

ngx_header_set
--------------
* **syntax:** `bool ngx_header_set(string $key, string $value)`

ngx_header_get
--------------
* **syntax:** `string ngx_header_get(string $key)`

ngx_header_gets
---------------
* **syntax:** `array ngx_header_gets(void)`

ngx_redirect
------------
* **syntax:** `bool ngx_redirect(string $uri, int $status)`


Nginx non-blocking API for php
------------------------------
* [yield ngx_sleep](#ngx_sleep)
* [ngx_socket_create](#ngx_socket_create)
* [yield ngx_socket_connect](#ngx_socket_connect)
* [yield ngx_socket_close](#ngx_socket_close)
* [yield ngx_socket_send](#ngx_socket_send)
* [yield ngx_socket_recv](#ngx_socket_recv)

ngx_sleep
---------
* **syntax:** `yield ngx_sleep(int seconds)`

ngx_socket_create
-----------------
* **syntax:** `resource ngx_socket_create(int $domain, int $type, int $protocol)`

ngx_socket_connect
------------------
* **syntax:** `bool ( yield ngx_socket_connect(resource $socket, string $address, int $port) )`

ngx_socket_close
----------------
* **syntax:** `bool ( yield ngx_socket_close(resource $socket) )`

ngx_socket_send
---------------
* **syntax:** `int ( yield ngx_socket_send(resource $socket, string $buf, int $len) )`

ngx_socket_recv
---------------
* **syntax:** `int ( yield ngx_socket_recv(resource $socket, string &$buf, int $len) )`


Copyright and License
---------------------
```
Copyright (c) 2016-2019, rryqszq4 <<EMAIL>>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:<commit_msg>[src] Update doc.<commit_after>ngx_php7
========
[![Build Status](https://travis-ci.org/rryqszq4/ngx_php7.svg?branch=master)](https://travis-ci.org/rryqszq4/ngx_php7)
[![GitHub release](https://img.shields.io/github/release/rryqszq4/ngx_php7.svg)](https://github.com/rryqszq4/ngx_php7/releases/latest)
[![license](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg)](https://github.com/rryqszq4/ngx_php7/blob/master/LICENSE)
[![QQ group](https://img.shields.io/badge/QQ--group-558795330-26bcf5.svg)](https://github.com/rryqszq4/ngx_php7)

![](https://raw.githubusercontent.com/rryqszq4/ngx_php7/master/docs/hello_world_performance.png)

ngx_php7 is an extension module of high-performance web server nginx, which implements embedded php7 script to process nginx location and variables.  

ngx_php7 draws on the design of [ngx_lua](https://github.com/openresty/lua-nginx-module) and is committed to providing non-blocking web services with significant performance advantages over php-cgi, mod_php, php-fpm and hhvm.  

ngx_php7 doesn't want to replace anything, just want to provide a solution.  

There is a legacy version of [ngx_php5](https://github.com/rryqszq4/ngx_php/tree/ngx_php5), which records some of my past code practices and is also valuable.   

[Benchmarks about ngx_php7 and php](https://www.techempower.com/benchmarks/#section=test&runid=76a34044-54d6-4349-adfe-863c2d5ae756&hw=ph&test=plaintext&l=zik073-7)  

What's different with official php
----------------------------------
* Global variable is unsafe in per request
* Static variable of a class is unsafe in per request
* Do not design singleton mode
* The native IO function works fine, but it slows down nginx

Requirement
-----------
- PHP-7.0.* ~ PHP-7.3.*
- nginx-1.4.7 ~ nginx-1.14.2 and mainline 1.15.7

Installation
------------

### Compile install

```sh
$ wget 'http://php.net/distributions/php-7.2.14.tar.gz'
$ tar xf php-7.2.14.tar.gz
$ cd php-7.2.14

$ ./configure --prefix=/path/to/php --enable-embed
$ make && make install

$ git clone https://github.com/rryqszq4/ngx_php7.git

$ wget 'http://nginx.org/download/nginx-1.12.2.tar.gz'
$ tar -zxvf nginx-1.12.2.tar.gz
$ cd nginx-1.12.2

$ export PHP_CONFIG=/path/to/php/bin/php-config
$ export PHP_BIN=/path/to/php/bin
$ export PHP_INC=/path/to/php/include/php
$ export PHP_LIB=/path/to/php/lib

$ ./configure --user=www --group=www \
$             --prefix=/path/to/nginx \
$             --with-ld-opt="-Wl,-rpath,$PHP_LIB" \
$             --add-module=/path/to/ngx_php7/third_party/ngx_devel_kit \
$             --add-module=/path/to/ngx_php7
$ make && make install
```

### CentOS / RedHat 7

```sh
yum -y install https://extras.getpagespeed.com/release-el7-latest.rpm
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
yum-config-manager --enable remi-php73
yum install nginx-module-php7
```

Edit `nginx.conf` and load the required modules at the top:

    load_module modules/ndk_http_module.so;
    load_module modules/ngx_http_php_module.so;

### Docker

```sh
$ docker build -t nginx-php7 .
$ : "app.conf: Create nginx config"
$ docker run -p 80:80 -v $PWD/app.conf:/etc/nginx/conf.d/default.conf nginx-php7
```


Synopsis
--------

```nginx
user www www;
worker_processes  4;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;
    
    client_max_body_size 64k;   
    client_body_buffer_size 64k;

    php_ini_path /usr/local/php/etc/php.ini;

    server {
        listen       80;
        server_name  localhost;
        default_type 'application/json; charset=UTF-8';
    
        location /php {
            content_by_php '
                echo "hello ngx_php7";
            ';
        }

        location = /ngx_request {
            content_by_php '
                echo ngx_request::document_uri();
            ';
        }

        # curl /ngx_get?a=1&b=2
        location = /ngx_get {
            content_by_php '
                echo "ngx::query_args()\n";
                var_dump(ngx::query_args());
            ';
        }

        # curl -d 'a=1&b=2' /ngx_post
        location = /ngx_post {
            content_by_php '
                echo "ngx::post_args()\n";
                var_dump(ngx::post_args());
            ';
        }

        location = /ngx_sleep {
            content_by_php '
                echo "ngx_sleep start\n";
                yield ngx::sleep(1);
                echo "ngx_sleep end\n";
            ';
        }

        location = /ngx_socket2 {
            default_type 'application/json;charset=UTF-8';
            content_by_php '
                $fd = ngx_socket_create();
                var_dump($fd);
                yield ngx_socket_connect($fd, "hq.sinajs.cn", 80);
                $send_buf = "GET /list=s_sh000001 HTTP/1.0\r\n
                                            Host: hq.sinajs.cn\r\nConnection: close\r\n\r\n";
                yield ngx_socket_send($fd, $send_buf, strlen($send_buf));
                $recv_buf = "";
                yield ngx_socket_recv($fd, $recv_buf);
                var_dump($recv_buf);
                yield ngx_socket_close($fd);
            ';
        }

        location = /ngx_var {
            set $a 1234567890;
            content_by_php '
                $a = ngx_var::get("a");
                var_dump($a);
            ';
        }
        
        # set content-type of response headers
        location = /ngx_header {
            content_by_php '
                ngx_header_set("Content-Type", "text/html; charset=UTF-8");
            ';
        }

        # run a php file
        location = /php {
            content_by_php '
                include "name_of_php_file.php";
            ';
        }
        
        # run any php file in root
        location = / {
            content_by_php '
                include ngx_var::get("uri");
            ';
        }

    }
}
```

Test
----
Using the perl of [Test::Nginx](https://github.com/openresty/test-nginx) module to testing, searching and finding out problem in ngx_php7.
```sh
ngx_php7 test ...
nginx version: nginx/1.10.3
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 
configure arguments: --prefix=/home/travis/build/rryqszq4/ngx_php7/build/nginx --with-ld-opt=-Wl,-rpath,/home/travis/build/rryqszq4/ngx_php7/build/php/lib --add-module=../../../ngx_php7/third_party/ngx_devel_kit --add-module=../../../ngx_php7
t/001-hello.t ........... ok
t/002-ini.t ............. ok
t/004-ngx_request.t ..... ok
t/005-ngx_log.t ......... ok
t/006-ngx_sleep.t ....... ok
t/007-ngx_socket.t ...... ok
t/008-ngx_exit.t ........ ok
t/009-ngx_query_args.t .. ok
t/010-ngx_post_args.t ... ok
t/011-ngx_constants.t ... ok
t/012-function.t ........ ok
t/013-class.t ........... ok
t/014-ngx_var.t ......... ok
All tests successful.
Files=13, Tests=28,  5 wallclock secs ( 0.05 usr  0.02 sys +  1.26 cusr  0.22 csys =  1.55 CPU)
Result: PASS
```

Directives
----------
* [php_ini_path](#php_ini_path)
* [init_worker_by_php](#init_worker_by_php)
* [rewrite_by_php](#rewrite_by_php)
* [access_by_php](#access_by_php)
* [content_by_php](#content_by_php)
* [log_by_php](#log_by_php)
* [header_filter_by_php](#header_filter_by_php)
* [body_filter_by_php](#body_filter_by_php)

php_ini_path
------------
* **syntax:** `php_ini_path`_`<php.ini file path>`_
* **context:** `http`
* **phase:** `loading-config`

init_worker_by_php
------------------
* **syntax:** `init_worker_by_php`_`<php script code>`_
* **context:** `http`
* **phase:** `starting-worker`

rewrite_by_php
--------------
* **syntax:** `rewrite_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `rewrite`

access_by_php
-------------
* **syntax:** `access_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `access`

content_by_php
--------------
* **syntax:** `content_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `content`

log_by_php
----------
* **syntax:** `log_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `log`

header_filter_by_php
--------------------
* **syntax:** `header_filter_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `output-header-filter`

body_filter_by_php
------------------
* **syntax:** `body_filter_by_php`_`<php script code>`_
* **context:** `http, server, location, location if`
* **phase:** `output-body-filter`


Nginx API for php
-----------------
* [ngx_exit](#ngx_exit)
* [ngx_query_args](#ngx_query_args)
* [ngx_post_args](#ngx_post_args)
* [ngx_log_error](#ngx_log_error)
* [ngx_request_method](#ngx_request_method)
* [ngx_request_document_root](#ngx_request_document_root)
* [ngx_request_document_uri](#ngx_request_document_uri)
* [ngx_request_script_name](#ngx_request_script_name)
* [ngx_request_script_filename](#ngx_request_script_filename)
* [ngx_request_query_string](#ngx_request_query_string)
* [ngx_request_uri](#ngx_request_uri)
* [ngx_request_server_protocol](#ngx_request_server_protocol)
* [ngx_request_remote_addr](#ngx_request_remote_addr)
* [ngx_request_server_addr](#ngx_request_server_addr)
* [ngx_request_remote_port](#ngx_request_remote_port)
* [ngx_request_server_port](#ngx_request_server_port)
* [ngx_request_server_name](#ngx_request_server_name)
* [ngx_request_headers](#ngx_request_headers)
* [ngx_var_get](#ngx_var_get)
* [ngx_var_set](#ngx_var_set)
* [ngx_header_set](#ngx_header_set)
* [ngx_header_get](#ngx_header_get)
* [ngx_header_gets](#ngx_header_gets)
* [ngx_redirect](#ngx_redirect)

ngx_exit
--------
* **syntax:** `ngx_exit(int $status) : void`

ngx_query_args
--------------
* **syntax:** `ngx_query_args(void) : array` or `ngx::query_args(void) : array`

ngx_post_args
-------------
* **syntax:** `ngx_post_args(void) : array` or `ngx::post_args(void) : array`

ngx_log_error
-------------
* **syntax:** `ngx_log_error(int $level, string $log_str) : void` or `ngx_log::error(int $level, string $log_str) : void`

ngx_request_method
------------------
* **syntax:** `ngx_request_method(void) : string` or `ngx_request::method(void) : string`

ngx_request_document_root
-------------------------
* **syntax:** `ngx_request_document_root(void) : string` or `ngx_request::document_root(void) : string`

ngx_request_document_uri
------------------------
* **syntax:** `ngx_request_document_uri(void) : string` or `ngx_request::document_uri(void) : string`

ngx_request_script_name
-----------------------
* **syntax:** `ngx_request_script_name(void) : string` or `ngx_request::script_name(void) : string`

ngx_request_script_filename
---------------------------
* **syntax:** `ngx_request_script_filename(void) : string` or `ngx_request::script_filename(void) : string`

ngx_request_query_string
------------------------
* **syntax:** `ngx_request_query_string(void) : string` or `ngx_request::query_string(void) : string`

ngx_request_uri
---------------
* **syntax:** `ngx_request_uri(void) : string` or `ngx_request::uri(void) : string`

ngx_request_server_protocol
---------------------------
* **syntax:** `ngx_request_server_protocol(void) : string` or `ngx_request::server_protocol(void) : string`

ngx_request_remote_addr
-----------------------
* **syntax:** `ngx_request_remote_addr(void) : string` or `ngx_request::remote_addr(void) : string`

ngx_request_server_addr
-----------------------
* **syntax:** `ngx_request_server_addr(void) : string` or `ngx_request::server_addr(void) : string`

ngx_request_remote_port
-----------------------
* **syntax:** `ngx_request_remote_port(void) : int` or `ngx_request::remote_port(void) : int`

ngx_request_server_port
-----------------------
* **syntax:** `ngx_request_server_port(void) : int` or `ngx_request::server_port(void) : int`

ngx_request_server_name
-----------------------
* **syntax:** `ngx_request_server_name(void) : string` or `ngx_request::server_name(void) : string`

ngx_request_headers
-------------------
* **syntax:** `ngx_request_headers(void): array` or `ngx_request::headers(void) : array`

ngx_var_get
-----------
* **syntax:** `ngx_var_get(string $key) : string` or `ngx_var::get(string $key) : string`

ngx_var_set
-----------
* **syntax:** `ngx_var_set(string $key, string $value) : void` or `ngx_var::set(string $key, string $value) : void`

ngx_header_set
--------------
* **syntax:** `ngx_header_set(string $key, string $value) : bool`

ngx_header_get
--------------
* **syntax:** `ngx_header_get(string $key) : string`

ngx_header_gets
---------------
* **syntax:** `ngx_header_gets(void) : array`

ngx_redirect
------------
* **syntax:** `ngx_redirect(string $uri, int $status) : bool`


Nginx non-blocking API for php
------------------------------
* [yield ngx_sleep](#ngx_sleep)
* [ngx_socket_create](#ngx_socket_create)
* [ngx_socket_iskeepalive](#ngx_socket_iskeepalive)
* [yield ngx_socket_connect](#ngx_socket_connect)
* [yield ngx_socket_close](#ngx_socket_close)
* [yield ngx_socket_send](#ngx_socket_send)
* [yield ngx_socket_recv](#ngx_socket_recv)

ngx_sleep
---------
* **syntax:** `yield ngx_sleep(int seconds)`

ngx_socket_create
-----------------
* **syntax:** `ngx_socket_create(int $domain, int $type, int $protocol) : resource`

ngx_socket_iskeepalive
----------------------
* **syntax:** `ngx_socket_iskeepalive(void) : bool`

ngx_socket_connect
------------------
* **syntax:** `( yield ngx_socket_connect(resource $socket, string $address, int $port) ) : bool`

ngx_socket_close
----------------
* **syntax:** `( yield ngx_socket_close(resource $socket) ) : bool`

ngx_socket_send
---------------
* **syntax:** `( yield ngx_socket_send(resource $socket, string $buf, int $len) ) : int`

ngx_socket_recv
---------------
* **syntax:** `( yield ngx_socket_recv(resource $socket, string &$buf, int $len) ) : int`


Copyright and License
---------------------
```
Copyright (c) 2016-2019, rryqszq4 <<EMAIL>>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
{'fraction_non_alphanumeric': 0.20004269854824935, 'fraction_numerical': 0.018004554511813264, 'mean_word_length': 2.832674212464203, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 30, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4239175', 'n_tokens_mistral': 10539, 'n_tokens_neox': 9869, 'n_words': 1722}