{"id":13813013,"url":"https://github.com/rryqszq4/ngx-php","last_synced_at":"2025-05-15T09:07:39.804Z","repository":{"id":42496264,"uuid":"54710210","full_name":"rryqszq4/ngx-php","owner":"rryqszq4","description":"ngx-php - Embedded php7 or php8 scripting language for nginx module.  Mainline development version of the ngx-php.","archived":false,"fork":false,"pushed_at":"2025-02-10T06:41:17.000Z","size":1604,"stargazers_count":672,"open_issues_count":49,"forks_count":56,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-08T09:02:31.118Z","etag":null,"topics":["module","nginx","nginx-module","php","php7","php8"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rryqszq4.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-25T09:49:21.000Z","updated_at":"2025-05-02T10:24:38.000Z","dependencies_parsed_at":"2024-01-13T14:47:42.752Z","dependency_job_id":"653f3fad-6481-4a33-adf5-ec6c0e0c1bb2","html_url":"https://github.com/rryqszq4/ngx-php","commit_stats":null,"previous_names":["rryqszq4/ngx_php7"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rryqszq4%2Fngx-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rryqszq4%2Fngx-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rryqszq4%2Fngx-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rryqszq4%2Fngx-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rryqszq4","download_url":"https://codeload.github.com/rryqszq4/ngx-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254310515,"owners_count":22049469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["module","nginx","nginx-module","php","php7","php8"],"created_at":"2024-08-04T04:01:00.097Z","updated_at":"2025-05-15T09:07:34.791Z","avatar_url":"https://github.com/rryqszq4.png","language":"C","readme":"ngx-php\n========\n[![Build](https://github.com/rryqszq4/ngx-php/actions/workflows/build.yml/badge.svg)](https://github.com/rryqszq4/ngx-php/actions/workflows/build.yml)\n[![GitHub release](https://img.shields.io/github/release/rryqszq4/ngx-php.svg)](https://github.com/rryqszq4/ngx-php/releases/latest)\n[![license](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg)](https://github.com/rryqszq4/ngx-php/blob/master/LICENSE)\n[![QQ group](https://img.shields.io/badge/QQ--group-558795330-26bcf5.svg)](https://github.com/rryqszq4/ngx-php)\n[![Build Nightly PHP](https://github.com/rryqszq4/ngx-php/actions/workflows/build_development.yml/badge.svg)](https://github.com/rryqszq4/ngx-php/actions/workflows/build_development.yml)\n\nngx-php is an extension module of high-performance web server nginx, which implements embedded PHP7 and PHP8 script to process nginx location and variables.  \n\nngx-php 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.  \n\nngx-php doesn't want to replace anything, just want to provide a solution.  \n\nThere 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.   \n\n[Benchmarks about ngx-php and php](https://www.techempower.com/benchmarks/#section=data-r19\u0026hw=ph\u0026test=fortune)  \n\nTable of contents\n-----------------\n* [What's different with official php](#Whats-different-with-official-php)\n* [Requirement](#Requirement)\n* [Installation](#Installation)\n* [Synopsis](#Synopsis)\n* [Test](#Test)\n* [Directives](#Directives)\n* [Nginx API for php](#Nginx-API-for-php)\n* [Nginx non-blocking API for php](#Nginx-non-blocking-API-for-php)\n* [Nginx constants](#Nginx-constants)\n* [Copyright and License](#Copyright-and-License)\n\nWhat's different with official php\n----------------------------------\n* Global variable is unsafe in per request\n* Static variable of a class is unsafe in per request\n* Do not design singleton mode\n* The native IO function works fine, but it slows down nginx\n\nRequirement\n-----------\n- Linux only\n- PHP-7.* ~ PHP-8.3\n- nginx-1.4.7 ~ nginx-1.26.x\n\nInstallation\n------------\n\n### Compile install\n\n```sh\n$ wget 'http://php.net/distributions/php-7.3.10.tar.gz'\n$ tar xf php-7.3.10.tar.gz\n$ cd php-7.3.10\n\n$ ./configure --prefix=/path/to/php --enable-embed\n$ make \u0026\u0026 make install\n\n$ git clone https://github.com/rryqszq4/ngx-php.git\n\n$ wget 'http://nginx.org/download/nginx-1.12.2.tar.gz'\n$ tar -zxvf nginx-1.12.2.tar.gz\n$ cd nginx-1.12.2\n\n$ export PHP_CONFIG=/path/to/php/bin/php-config\n$ export PHP_BIN=/path/to/php/bin\n$ export PHP_INC=/path/to/php/include/php\n$ export PHP_LIB=/path/to/php/lib\n\n$ ./configure --user=www --group=www \\\n$             --prefix=/path/to/nginx \\\n$             --with-ld-opt=\"-Wl,-rpath,$PHP_LIB\" \\\n$             --add-module=/path/to/ngx-php/third_party/ngx_devel_kit \\\n$             --add-module=/path/to/ngx-php\n$ make \u0026\u0026 make install\n```\n\n### CentOS / RedHat 7\n\n```sh\nyum -y install https://extras.getpagespeed.com/release-el7-latest.rpm\nyum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils\nyum-config-manager --enable remi-php73\nyum install nginx-module-php7\n```\n\nEdit `nginx.conf` and load the required modules at the top:\n\n    load_module modules/ndk_http_module.so;\n    load_module modules/ngx_http_php_module.so;\n\n### Ubuntu\n```sh\napt-get update -yqq \u0026\u0026 apt-get install -yqq software-properties-common\nLC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php\napt-get update -yqq\napt-get install -yqq wget git unzip libxml2-dev cmake make systemtap-sdt-dev \\\n                     zlib1g-dev libpcre3-dev libargon2-0-dev libsodium-dev libkrb5-dev \\\n                     php7.4-cli php7.4-dev libphp7.4-embed php7.4-mysql\n\ngit clone https://github.com/rryqszq4/ngx-php.git\n\nwget 'http://nginx.org/download/nginx-1.18.0.tar.gz'\ntar -zxvf nginx-1.18.0.tar.gz\ncd nginx-1.18.0\n\nexport PHP_LIB=/usr/lib\n\n./configure --user=www --group=www \\\n            --prefix=/path/to/nginx \\\n            --with-ld-opt=\"-Wl,-rpath,$PHP_LIB\" \\\n            --add-module=/path/to/ngx-php/third_party/ngx_devel_kit \\\n            --add-module=/path/to/ngx-php\nmake \u0026\u0026 make install\n```\n\n### Mac osx\n[https://github.com/rryqszq4/ngx-php/blob/master/docs/zh-cn/osx_install.md](https://github.com/rryqszq4/ngx-php/blob/master/docs/zh-cn/osx_install.md)  \n\n### Docker\n\n```sh\n$ docker build -t nginx-php7 .\n$ : \"app.conf: Create nginx config\"\n$ docker run -p 80:80 -v $PWD/app.conf:/etc/nginx/conf.d/default.conf nginx-php7\n```\n\n\nSynopsis\n--------\n\n```nginx\nworker_processes  auto;\n\nevents {\n    worker_connections  102400;\n}\n\nhttp {\n    include       mime.types;\n    default_type  application/octet-stream;\n\n    keepalive_timeout  65;\n    \n    client_max_body_size 64k;   \n    client_body_buffer_size 64k;\n\n    php_ini_path /usr/local/php/etc/php.ini;\n\n    server {\n        listen       80;\n        server_name  localhost;\n        default_type 'application/json; charset=UTF-8';\n    \n        location /php {\n            content_by_php_block {\n                echo \"hello ngx-php\";\n            }\n        }\n\n        location = /ngx_request {\n            content_by_php_block {\n                echo ngx_request_document_uri();\n            }\n        }\n\n        # curl /ngx_get?a=1\u0026b=2\n        location = /ngx_get {\n            content_by_php_block {\n                echo \"ngx_query_args()\\n\";\n                var_dump(ngx_query_args());\n            }\n        }\n\n        # curl -d 'a=1\u0026b=2' /ngx_post\n        location = /ngx_post {\n            content_by_php_block {\n                echo \"ngx_post_args()\\n\";\n                var_dump(ngx_post_args());\n            }\n        }\n\n        location = /ngx_sleep {\n            content_by_php_block {\n                echo \"ngx_sleep start\\n\";\n                yield ngx_sleep(1);\n                echo \"ngx_sleep end\\n\";\n            }\n        }\n\n        location = /ngx_socket2 {\n            default_type 'application/json;charset=UTF-8';\n            content_by_php_block {\n                $fd = ngx_socket_create();\n\n                yield ngx_socket_connect($fd, \"httpbin.org\", 80);\n\n                $send_buf = \"GET /get HTTP/1.1\\r\\n\n                                            Host: httpbin.org\\r\\n\n                                            Connection: close\\r\\n\\r\\n\";\n                yield ngx_socket_send($fd, $send_buf, strlen($send_buf));\n\n                $recv_buf = \"\";\n                yield ngx_socket_recv($fd, $recv_buf);\n                var_dump($recv_buf);\n                \n                yield ngx_socket_close($fd);\n            }\n        }\n\n        location = /ngx_var {\n            set $a 1234567890;\n            content_by_php_block {\n                $a = ngx_var_get(\"a\");\n                var_dump($a);\n            }\n        }\n        \n        # set content-type of response headers\n        location = /ngx_header {\n            content_by_php_block {\n                ngx_header_set(\"Content-Type\", \"text/html; charset=UTF-8\");\n            }\n        }\n\n        # run a php file\n        location = /php {\n            content_by_php_block {\n                include \"name_of_php_file.php\";\n            }\n        }\n        \n        # run any php file in root\n        location = / {\n            content_by_php_block {\n                include ngx_var_get(\"uri\");\n            }\n        }\n\n    }\n}\n```\n\nTest\n----\nUsing the perl of [Test::Nginx](https://github.com/openresty/test-nginx) module to testing, searching and finding out problem in ngx-php.\n```sh\nNgx-php test ...\nnginx version: nginx/1.22.1\nbuilt by gcc 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) \nconfigure arguments: --prefix=/home/runner/work/ngx-php/ngx-php/nginx --with-ld-opt=-Wl,-rpath,/usr/lib --add-module=../third_party/ngx_devel_kit --add-module=..\n/home/runner/work/ngx-php/ngx-php\nt/001-hello.t ..................... ok\nt/002-ini.t ....................... ok\nt/003-error.t ..................... ok\nt/004-ngx_request.t ............... ok\nt/005-ngx_log.t ................... ok\nt/006-ngx_sleep.t ................. ok\nt/007-ngx_socket.t ................ ok\nt/008-ngx_exit.t .................. ok\nt/009-ngx_query_args.t ............ ok\nt/010-ngx_post_args.t ............. ok\nt/011-ngx_constants.t ............. ok\nt/012-function.t .................. ok\nt/013-class.t ..................... ok\nt/014-ngx_var.t ................... ok\nt/015-ngx_header.t ................ ok\nt/016-rewrite_by_php.t ............ ok\nt/017-ngx_redirect.t .............. ok\nt/018-ngx_mysql.t ................. skipped: Fix later\nt/019-php_set.t ................... ok\nt/020-ngx_cookie.t ................ ok\nt/021-content_by_php_block.t ...... ok\nt/022-init_worker_by_php_block.t .. ok\nt/023-ngx_redis.t ................. ok\nt/024-ngx_request_body.t .......... ok\nt/025-opcache.t ................... ok\nAll tests successful.\nFiles=25, Tests=92, 16 wallclock secs ( 0.08 usr  0.04 sys +  4.56 cusr  0.93 csys =  5.61 CPU)\nResult: PASS\n```\n\nDirectives\n----------\n* [php_ini_path](#php_ini_path)\n* [init_worker_by_php](#init_worker_by_php)\n* [init_worker_by_php_block](#init_worker_by_php_block)\n* [rewrite_by_php](#rewrite_by_php)\n* [rewrite_by_php_block](#rewrite_by_php_block)\n* [access_by_php](#access_by_php)\n* [access_by_php_block](#access_by_php_block)\n* [content_by_php](#content_by_php)\n* [content_by_php_block](#content_by_php_block)\n* [log_by_php](#log_by_php)\n* [log_by_php_block](#log_by_php_block)\n* [header_filter_by_php](#header_filter_by_php)\n* [header_filter_by_php_block](#header_filter_by_php_block)\n* [body_filter_by_php](#body_filter_by_php)\n* [body_filter_by_php_block](#body_filter_by_php_block)\n* [php_keepalive](#php_keepalive)\n* [php_set](#php_set)\n* [php_socket_keepalive](#php_socket_keepalive)\n* [php_socket_buffer_size](#php_socket_buffer_size)\n\nphp_ini_path\n------------\n**syntax:** `php_ini_path`_`\u003cphp.ini file path\u003e`_\n\n**context:** `http`\n\n**phase:** `loading-config`\n\nThis directive allows loading the official php configuration file php.ini, which will be used by subsequent PHP code.\n\ninit_worker_by_php\n------------------\n**syntax:** `init_worker_by_php`_`\u003cphp script code\u003e`_\n\n**context:** `http`\n\n**phase:** `starting-worker`\n\ninit_worker_by_php_block\n------------------------\n**syntax:** `init_worker_by_php_block`_`{php script code}`_\n\n**context:** `http`\n\n**phase:** `starting-worker`\n\nrewrite_by_php\n--------------\n**syntax:** `rewrite_by_php`_`\u003cphp script code\u003e`_\n\n**context:** `http, server, location, location if`\n\n**phase:** `rewrite`\n\nIn the rewrite phase of nginx, you can execute inline php code.\n\nrewrite_by_php_block\n--------------------\n**syntax:** `rewrite_by_php_block`_`{php script code}`_\n\n**context:** `location, location if`\n\n**phase:** `rewrite`\n\nIn the rewrite phase of nginx, you can execute inline php code.\n\naccess_by_php\n-------------\n**syntax:** `access_by_php`_`\u003cphp script code\u003e`_\n\n**context:** `http, server, location, location if`\n\n**phase:** `access`\n\nIn the access phase of nginx, you can execute inline php code.\n\naccess_by_php_block\n-------------------\n**syntax:** `access_by_php_block`_`{php script code}`_\n\n**context:** `location, location if`\n\n**phase:** `access`\n\nIn the access phase of nginx, you can execute inline php code.\n\ncontent_by_php\n--------------\n**syntax:** `content_by_php`_`\u003cphp script code\u003e`_\n\n**context:** `http, server, location, location if`\n\n**phase:** `content`\n\nIn the content phase of nginx, you can execute inline php code.\n\ncontent_by_php_block\n--------------------\n**syntax:** `content_by_php_block`_`{php script code}`_\n\n**context:** `location, location if`\n\n**phase:** `content`\n\nIn the content phase of nginx, you can execute inline php code.\n\nlog_by_php\n----------\n**syntax:** `log_by_php`_`\u003cphp script code\u003e`_\n\n**context:** `http, server, location, location if`\n\n**phase:** `log`\n\nlog_by_php_block\n----------------\n**syntax:** `log_by_php_block`_`{php script code}`_\n\n**context:** `location, location if`\n\n**phase:** `log`\n\nheader_filter_by_php\n--------------------\n**syntax:** `header_filter_by_php`_`\u003cphp script code\u003e`_\n\n**context:** `http, server, location, location if`\n\n**phase:** `output-header-filter`\n\nheader_filter_by_php_block\n--------------------------\n**syntax:** `header_filter_by_php_block`_`{php script code}`_\n\n**context:** `location, location if`\n\n**phase:** `output-header-filter`\n\nbody_filter_by_php\n------------------\n**syntax:** `body_filter_by_php`_`\u003cphp script code\u003e`_\n\n**context:** `http, server, location, location if`\n\n**phase:** `output-body-filter`\n\nbody_filter_by_php_block\n------------------------\n**syntax:** `body_filter_by_php_block`_`{php script code}`_\n\n**context:** `location, location if`\n\n**phase:** `output-body-filter`\n\nphp_keepalive\n-------------\n**syntax:** `php_keepalive`_`\u003csize\u003e`_\n\n**default:** `0`\n\n**context:** `http, server`\n\nIn php, set upstream connection pool size.\n\nphp_set\n-------\n**syntax:** `php_set`_`$variable`_ _`\u003cphp script code\u003e`_\n\n**context:** `http, server, location, location if`\n\n**phase:** `loading-config`\n\nInstalls a php handler for the specified variable.\n\nphp_socket_keepalive\n--------------------\n**syntax:** `php_socket_keepalive`_`\u003csize\u003e`_\n\n**default:** `0`\n\n**context:** `http, server`\n\nphp_socket_buffer_size\n----------------------\n**syntax:** `php_socket_buffer_size`_`\u003csize\u003e`_\n\n**default:** `4k`\n\n**context:** `http, server, location, location if`\n\nNginx API for php\n-----------------\n* [ngx_exit](#ngx_exit)\n* [ngx_query_args](#ngx_query_args)\n* [ngx_post_args](#ngx_post_args)\n* [ngx_log_error](#ngx_log_error)\n* [ngx_request_method](#ngx_request_method)\n* [ngx_request_document_root](#ngx_request_document_root)\n* [ngx_request_document_uri](#ngx_request_document_uri)\n* [ngx_request_script_name](#ngx_request_script_name)\n* [ngx_request_script_filename](#ngx_request_script_filename)\n* [ngx_request_query_string](#ngx_request_query_string)\n* [ngx_request_uri](#ngx_request_uri)\n* [ngx_request_server_protocol](#ngx_request_server_protocol)\n* [ngx_request_remote_addr](#ngx_request_remote_addr)\n* [ngx_request_server_addr](#ngx_request_server_addr)\n* [ngx_request_remote_port](#ngx_request_remote_port)\n* [ngx_request_server_port](#ngx_request_server_port)\n* [ngx_request_server_name](#ngx_request_server_name)\n* [ngx_request_headers](#ngx_request_headers)\n* [ngx_var_get](#ngx_var_get)\n* [ngx_var_set](#ngx_var_set)\n* [ngx_header_set](#ngx_header_set)\n* [ngx_header_get](#ngx_header_get)\n* [ngx_header_get_all](#ngx_header_get_all)\n* [ngx_redirect](#ngx_redirect)\n* [ngx_cookie_get_all](#ngx_cookie_get_all)\n* [ngx_cookie_get](#ngx_cookie_get)\n* [ngx_cookie_set](#ngx_cookie_set)\n\nngx_exit\n--------\n**syntax:** `ngx_exit(int $status) : void`\n\n**parameters:**\n- `status: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nEnd of current request and return http status code.\n\nngx_query_args\n--------------\n**syntax:** `ngx_query_args(void) : array` or `ngx::query_args(void) : array`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nAn associative array of variables passed to the current script via the URL parameters (aka. query string).  \nInstead of php official constant $_GET.\n\nngx_post_args\n-------------\n**syntax:** `ngx_post_args(void) : array` or `ngx::post_args(void) : array`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nAn associative array of variables passed to the current script via the HTTP POST method  \nwhen using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request.  \nInstead of php official constant $_POST.\n\nngx_log_error\n-------------\n**syntax:** `ngx_log_error(int $level, string $log_str) : void` or `ngx_log::error(int $level, string $log_str) : void`\n\n**parameters:**\n- `level: int`\n- `log_str: string`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_request_method\n------------------\n**syntax:** `ngx_request_method(void) : string` or `ngx_request::method(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nWhich request method was used to access the page, such as 'GET','POST','PUT','DELETE' and so on.\n\nngx_request_document_root\n-------------------------\n**syntax:** `ngx_request_document_root(void) : string` or `ngx_request::document_root(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe document root directory under which the current script is executing, as defined in the server's configuration file.\n\nngx_request_document_uri\n------------------------\n**syntax:** `ngx_request_document_uri(void) : string` or `ngx_request::document_uri(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_request_script_name\n-----------------------\n**syntax:** `ngx_request_script_name(void) : string` or `ngx_request::script_name(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nContains the current script'path. This is useful for pages which need to point to the themselves.  \nThe __FILE__ constant contains the full path and filename of the current (included) file.\n\nngx_request_script_filename\n---------------------------\n**syntax:** `ngx_request_script_filename(void) : string` or `ngx_request::script_filename(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe absolute pathname of the currently executing script file name.\n\nngx_request_query_string\n------------------------\n**syntax:** `ngx_request_query_string(void) : string` or `ngx_request::query_string(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe query string, if any, via which the page was accessed.\n\nngx_request_uri\n---------------\n**syntax:** `ngx_request_uri(void) : string` or `ngx_request::uri(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe URI which was given in order to access this page, for instance, '/index.html'.\n\nngx_request_server_protocol\n---------------------------\n**syntax:** `ngx_request_server_protocol(void) : string` or `ngx_request::server_protocol(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nName and revision of th information protocol via which the page was requested, such as 'HTTP/1.0'.\n\nngx_request_remote_addr\n-----------------------\n**syntax:** `ngx_request_remote_addr(void) : string` or `ngx_request::remote_addr(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe IP address from which the user is viewing the current page.\n\nngx_request_server_addr\n-----------------------\n**syntax:** `ngx_request_server_addr(void) : string` or `ngx_request::server_addr(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe IP address of the server under which the current script is executing.\n\nngx_request_remote_port\n-----------------------\n**syntax:** `ngx_request_remote_port(void) : int` or `ngx_request::remote_port(void) : int`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe port being used on the user's machine to communicate with the web server.\n\nngx_request_server_port\n-----------------------\n**syntax:** `ngx_request_server_port(void) : int` or `ngx_request::server_port(void) : int`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe port on the server machine being used by the web server for communication. For default setups,  \nthis will be '80'; using SSL, for instance, will change this to whatever your defined secure HTTP port is.\n\nngx_request_server_name\n-----------------------\n**syntax:** `ngx_request_server_name(void) : string` or `ngx_request::server_name(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe name of the server host under which the current script is executing.   \nIf the script is running on a virtual host, this will be the value defined for that virtual host.\n\nngx_request_headers\n-------------------\n**syntax:** `ngx_request_headers(void): array` or `ngx_request::headers(void) : array`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nGet the header full information of the http request.\n\nngx_var_get\n-----------\n**syntax:** `ngx_var_get(string $key) : string` or `ngx_var::get(string $key) : string`\n\n**parameters:**\n- `key: string`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nGet the variables in the nginx configuration.\n\nngx_var_set\n-----------\n**syntax:** `ngx_var_set(string $key, string $value) : void` or `ngx_var::set(string $key, string $value) : void`\n\n**parameters:**\n- `key: string`\n- `value: string`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nSet the variables in the nginx configuration.\n\nngx_header_set\n--------------\n**syntax:** `ngx_header_set(string $key, string $value) : bool`\n\n**parameters:**\n- `key: string`\n- `value: string`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nSet the header information of the http response.\n\nngx_header_get\n--------------\n**syntax:** `ngx_header_get(string $key) : string`\n\n**parameters:**\n- `key: string`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nGet the header information of the http response.\n\nngx_header_gets\n---------------\n**syntax:** `ngx_header_gets(void) : array`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nGet the header full information of the http response.\n\nngx_redirect\n------------\n**syntax:** `ngx_redirect(string $uri, int $status) : bool`\n\n**parameters:**\n- `uri: string`\n- `status: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nSet response header redirection.\n\nngx_cookie_get_all\n------------------\n**syntax:** `ngx_cookie_get_all(void) : string`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_cookie_get\n--------------\n**syntax:** `ngx_cookie_get(string $key) : string`\n\n**parameters:**\n- `key: string`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_cookie_set\n--------------\n**syntax:** `ngx_cookie_set(string $data): bool`\n\n**parameters:**\n- `data: string`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\n\nNginx non-blocking API for php\n------------------------------\n* [yield ngx_sleep](#ngx_sleep)\n* [yield ngx_msleep](#ngx_msleep)\n* [ngx_socket_create](#ngx_socket_create)\n* [ngx_socket_iskeepalive](#ngx_socket_iskeepalive)\n* [yield ngx_socket_connect](#ngx_socket_connect)\n* [yield ngx_socket_close](#ngx_socket_close)\n* [yield ngx_socket_send](#ngx_socket_send)\n* [yield ngx_socket_recv](#ngx_socket_recv)\n* [yield ngx_socket_recvpage](#ngx_socket_recvpage)\n* [ngx_socket_recvsync](#ngx_socket_recvsync)\n* [ngx_socket_clear](#ngx_socket_clear)\n\nngx_sleep\n---------\n**syntax:** `yield ngx_sleep(int seconds)`\n\n**parameters:**\n- `secodes: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nDelays the program execution for the given number of seconds.\n\nngx_msleep\n---------\n**syntax:** `yield ngx_msleep(int milliseconds)`\n\n**parameters:**\n- `milliseconds: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nDelays the program execution for the given number of milliseconds.\n\nngx_socket_create\n-----------------\n**syntax:** `ngx_socket_create(int $domain, int $type, int $protocol) : resource`\n\n**parameters:**\n- `domain: int`\n- `type: int`\n- `protocol: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nCreates and returns a socket resource, also referred to as an endpoint of communication.  \nA typical network connection is made up of 2 sockets, one performing the role of the client,  \nand another performing the role of the server.\n\nngx_socket_iskeepalive\n----------------------\n**syntax:** `ngx_socket_iskeepalive(void) : bool`\n\n**parameters:**\n- `void`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_socket_connect\n------------------\n**syntax:** `( yield ngx_socket_connect(resource $socket, string $address, int $port) ) : bool`\n\n**parameters:**\n- `socket: resource`\n- `address: string`\n- `port: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nInitiate a connection to address using the socket resource socket, which must be a valid  \nsocket resource created with ngx_socket_create().\n\nngx_socket_close\n----------------\n**syntax:** `( yield ngx_socket_close(resource $socket) ) : bool`\n\n**parameters:**\n- `socket: resource`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_socket_close() closes the socket resource given by socket. This function is specific to  \nsockets and cannot be used on any other type of resources.\n\nngx_socket_send\n---------------\n**syntax:** `( yield ngx_socket_send(resource $socket, string $buf, int $len) ) : int`\n\n**parameters:**\n- `socket: resource`\n- `buf: string`\n- `len: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe function ngx_socket_send() sends len bytes to the socket socket from buf.\n\nngx_socket_recv\n---------------\n**syntax:** `( yield ngx_socket_recv(resource $socket, string \u0026$buf, int $len) ) : int`\n\n**parameters:**\n- `socket: resource`\n- `buf: string`\n- `len: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nThe ngx_socket_recv() function receives len bytes of data in buf from socket. ngx_socket_recv() can be  \nused to gather data from connected sockets. \n\nbuf is passed by reference, so it must be specified as a variable in the argument list.  \nData read from socket by ngx_socket_recv() will be returned in buf.\n\nngx_socket_recvpage\n-------------------\n**syntax:** `( yield ngx_socket_recvpage(resource $socket, string \u0026$buf, int \u0026$rc) ) : int`\n\n**parameters:**\n- `socket: resource`\n- `buf: string`\n- `rc: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_socket_recvsync\n-------------------\n**syntax:** `ngx_socket_recvsync(resource $socket, string \u0026$buf, int $len) : int`\n\n**parameters:**\n- `socket: resource`\n- `buf: string`\n- `len: int`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nngx_socket_clear\n----------------\n**syntax:** `ngx_socket_recv(resource $socket) : bool`\n\n**parameters:**\n- `socket: resource`\n\n**context:** `rewrite_by_php*, access_by_php*, content_by_php*`\n\nClose the socket resource and is blocking but hight performance.\n\nNginx constants\n---------------\n* [version constants](#version-constants)\n* [log constants for php](#log-constants-for-php)\n* [status constants for php](#status-constants-for-php)\n* [http status constants for php](#http-status-constants-for-php)\n\nversion constants\n-----------------\nname | value\n-|-\nNGINX_VAR                       | NGINX\nNGINX_VERSION                   | 1.12.2\nNGX_HTTP_PHP_MODULE_VERSION     | 0.0.21\nNGX_HTTP_PHP_MODULE_NAME        | ngx_php\n\nlog constants for php\n---------------------\nname | value\n-|-\nNGX_OK          | 0\nNGX_ERROR       | -1\nNGX_AGAIN       | -2\nNGX_BUSY        | -3\nNGX_DONE        | -4\nNGX_DECLINED    | -5\nNGX_ABORT       | -6\n\nstatus constants for php\n------------------------\nname | value\n-|-\nNGX_LOG_STDERR  | 0\nNGX_LOG_EMERG   | 1\nNGX_LOG_ALERT   | 2\nNGX_LOG_CRIT    | 3\nNGX_LOG_ERR     | 4\nNGX_LOG_WARN    | 5\nNGX_LOG_NOTICE  | 6\nNGX_LOG_INFO    | 7\nNGX_LOG_DEBUG   | 8\n\nhttp status constants for php\n-----------------------------\nname | value\n-|-\nNGX_HTTP_CONTINUE                   | 100\nNGX_HTTP_SWITCHING_PROTOCOLS        | 101\nNGX_HTTP_PROCESSING                 | 102\nNGX_HTTP_OK                         | 200\nNGX_HTTP_CREATED                    | 201\nNGX_HTTP_ACCEPTED                   | 202\nNGX_HTTP_NO_CONTENT                 | 204\nNGX_HTTP_PARTIAL_CONTENT            | 206\nNGX_HTTP_SPECIAL_RESPONSE           | 300\nNGX_HTTP_MOVED_PERMANENTLY          | 301\nNGX_HTTP_MOVED_TEMPORARILY          | 302\nNGX_HTTP_SEE_OTHER                  | 303\nNGX_HTTP_NOT_MODIFIED               | 304\nNGX_HTTP_TEMPORARY_REDIRECT         | 307\nNGX_HTTP_PERMANENT_REDIRECT         | 308\nNGX_HTTP_BAD_REQUEST                | 400\nNGX_HTTP_UNAUTHORIZED               | 401\nNGX_HTTP_FORBIDDEN                  | 403\nNGX_HTTP_NOT_FOUND                  | 404\nNGX_HTTP_NOT_ALLOWED                | 405\nNGX_HTTP_REQUEST_TIME_OUT           | 408\nNGX_HTTP_CONFLICT                   | 409\nNGX_HTTP_LENGTH_REQUIRED            | 411\nNGX_HTTP_PRECONDITION_FAILED        | 412\nNGX_HTTP_REQUEST_ENTITY_TOO_LARGE   | 413\nNGX_HTTP_REQUEST_URI_TOO_LARGE      | 414\nNGX_HTTP_UNSUPPORTED_MEDIA_TYPE     | 415\nNGX_HTTP_RANGE_NOT_SATISFIABLE      | 416\nNGX_HTTP_CLOSE                      | 444\nNGX_HTTP_NGINX_CODES                | 494\nNGX_HTTP_REQUEST_HEADER_TOO_LARGE   | 494\nNGX_HTTPS_CERT_ERROR                | 495\nNGX_HTTPS_NO_CERT                   | 496\nNGX_HTTP_TO_HTTPS                   | 497\nNGX_HTTP_CLIENT_CLOSED_REQUEST      | 499\nNGX_HTTP_INTERNAL_SERVER_ERROR      | 500\nNGX_HTTP_NOT_IMPLEMENTED            | 501\nNGX_HTTP_BAD_GATEWAY                | 502\nNGX_HTTP_SERVICE_UNAVAILABLE        | 503\nNGX_HTTP_GATEWAY_TIME_OUT           | 504\nNGX_HTTP_INSUFFICIENT_STORAGE       | 507\n\n\nCopyright and License\n---------------------\n```\nCopyright (c) 2016-2020, rryqszq4 \u003crryqszq@gmail.com\u003e\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n  list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n```\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frryqszq4%2Fngx-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frryqszq4%2Fngx-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frryqszq4%2Fngx-php/lists"}