{"id":341696,"date":"2022-11-24T21:00:21","date_gmt":"2022-11-24T21:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341696"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341696","title":{"rendered":"<span>\u041a\u0430\u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 runtime KPHP<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0434\u043d\u044f, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 runtime KPHP.<\/p>\n<p>\u0421\u043e\u0432\u0441\u0435\u043c \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 KPHP \u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 runtime KPHP.<\/p>\n<h3>\u041e KPHP<\/h3>\n<p>KPHP &#8212; \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 PHP. \u0414\u0435-\u0444\u0430\u043a\u0442\u043e PHP, \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 C++. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<h3>\u041e \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435<\/h3>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0440\u0435\u0448\u0438\u043c, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0441\u0442\u0440\u043e\u043a \u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ENV. \u0418\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 runtime.<\/p>\n<h3>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u043b\u0430\u043d\u0443:<\/p>\n<ol start=\"NaN\">\n<li>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<\/ol>\n<h4>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435<\/h4>\n<p>\u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043f\u043e\u0434 Ubuntu 20.04. \u0418 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 (\u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0438\u0445 \u043d\u0435\u0442):<\/p>\n<ul>\n<li>\n<p>git<\/p>\n<\/li>\n<li>\n<p>make, cmake<\/p>\n<\/li>\n<li>\n<p>g++,<\/p>\n<\/li>\n<li>\n<p>python3,<\/p>\n<\/li>\n<li>\n<p>pip3<\/p>\n<\/li>\n<li>\n<p>php7.4<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c vk`\u0448\u043d\u044b\u0435. \u0410 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438:<\/p>\n<pre><code class=\"bash\">sudo apt-get update  sudo apt-get install -y --no-install-recommends apt-utils ca-certificates gnupg wget  sudo wget -qO - https:\/\/repo.vkpartner.ru\/GPG-KEY.pub | sudo apt-key add -  echo \"deb https:\/\/repo.vkpartner.ru\/kphp-focal\/ focal main\" >> \/etc\/apt\/sources.list<\/code><\/pre>\n<p>\u0418 \u0443\u0436\u0435 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b:  <\/p>\n<pre><code class=\"bash\">sudo apt-get update  sudo apt install git cmake make g++ gperf python3-minimal python3-jsonschema \\             curl-kphp-vk libuber-h3-dev kphp-timelib libfmt-dev libgtest-dev libgmock-dev libre2-dev libpcre3-dev \\             libzstd-dev libyaml-cpp-dev libnghttp2-dev zlib1g-dev php7.4-dev libmysqlclient-dev libnuma-dev<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0434\u0435\u043b\u0430\u0432 \u044d\u0442\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u0431\u043e\u0440\u043a\u0435 KPHP \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432:<\/p>\n<pre><code class=\"bash\"># \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 git clone https:\/\/github.com\/VKCOM\/kphp.git  # \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f cd kphp  # \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0432\u0435\u0442\u043a\u0443 git checkout -b 'pmswga\/env_parsing'  # \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u043f\u043a\u0443 build mkdir build  # \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 build cd build  # \u041f\u0440\u043e\u0441\u0438\u043c cmake \u043f\u043e CMakeLists.txt \u0441\u043e\u0442\u043e\u0432\u0440\u0438\u0442\u044c \u043d\u0430\u043c \u0447\u0443\u0434\u043e cmake ..  # \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0438\u043c make \u0441\u043e\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0447\u0443\u0434\u043e  make -j6 all<\/code><\/pre>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u043e\u0439\u0442\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0427\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u0438\u0442\u043e\u0433\u0435? \u0412 \u043a\u043e\u0440\u043d\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 objs \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0440\u0438 \u043d\u0435\u0439:  <\/p>\n<pre><code class=\"bash\">kphp\/ \u251c\u2500 build\/                      &lt;-- \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0438, \u0442\u043e \u0432\u044b \u0442\u0443\u0442 :) \u251c\u2500 objs\/ \u2502  \u251c\u2500 bin\/ \u2502  \u2502  \u251c\u2500 kphp2cpp              &lt;-- \u041d\u0430\u0448 kphp \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 :( \u2502  \u2502  \u251c\u2500 tl2php \u2502  \u2502  \u251c\u2500 tl-compiler \u2502  \u251c\u2500 flex\/ \u2502  \u2502  \u251c\u2500 libvk-flex-data.o \u2502  \u2502  \u251c\u2500 libvk-flex-data.so \u2502  \u251c\u2500 generated\/* \u2502  \u251c\u2500 vkext\/ \u2502  \u2502  \u251c\u2500 modules\/ \u2502  \u2502  \u2502  \u251c\u2500 vkext.so \u2502  \u2502  \u251c\u2500 modules7.4\/ \u2502  \u2502  \u2502  \u251c\u2500 vkext.so<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043c\u044b \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e KPHP \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432. \u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u044b, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<h4>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e \u043e\u0431\u0440\u0438\u0441\u0443\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<pre><code class=\"bash\">kphp\/ \u251c\u2500 builin-functions\/_functions.txt  1) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u044e\u0434\u0430 \u251c\u2500 runtime\/ \u2502  \u251c\u2500 *.h                           2) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c h-\u0444\u0430\u0439\u043b\u044b \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0439  \u2502  \u251c\u2500 *.cpp                         3) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c cpp-\u0444\u0430\u0439\u043b\u044b \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2502  \u251c\u2500 runtime.cmake                 4) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 cpp-\u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e KPHP_RUNTIME_SOURCES<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c make \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0451 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ol start=\"NaN\">\n<li>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 _functions.txt \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <strong>parse_env_file<\/strong> \u0438 <strong>parse_env_string<\/strong>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043d\u0430 \u0442\u043e \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u044b. \u0412 \u0446\u0435\u043b\u043e\u043c \u0432\u0441\u0451 \u044f\u0441\u043d\u043e. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0442\u0440\u043e\u043a.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"go\">function parse_env_file($filename ::: string) ::: string[]; function parse_env_string($env_string ::: string) ::: string[];<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <strong>parsing_functions.h<\/strong> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">#pragma once  #include \"runtime\/kphp_core.h\" #include &lt;regex> #include &lt;fstream> #include &lt;sstream>  \/*  * Cool functions. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0441\u0442\u0440\u043e\u043a \u043e\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0433\u043e  *\/  string clearSpecSymbols(const string &amp;str);  string clearSpaces(const string &amp;str);  string clearEOL(const string &amp;str);  string clearQuotes(const string &amp;str);  string clearString(const string &amp;str);  string trim(const string &amp;str);  \/*  * The best funtions.   * \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c   * \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0447\u0430\u0441\u0442\u0438 \u043e\u0434\u043d\u043e\u0439 ENV-\u0437\u0430\u043f\u0438\u0441\u0438  *\/  bool isEnvComment(const string &amp;env_comment);  bool isEnvVar(const string &amp;env_var);  bool isEnvVal(const string &amp;env_val);  string get_env_var(const string &amp;env_entry);  string get_env_val(const string &amp;env_entry);  \/*  * Env file|string parsing functions.   * \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435  *\/  array&lt;string> f$parse_env_file(const string &amp;filename);  array&lt;string> f$parse_env_string(const string &amp;env_string);<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 <strong>parsing_functions.cpp<\/strong> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">#include \"parsing_functions.h\"  string clearSpecSymbols(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(R\"([\\t\\r\\b\\v])\"), \"\").c_str()   ); }  string clearSpaces(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(\" += +\"), \"=\").c_str()   ); }  string clearEOL(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(\"\\\\n\"), \" \").c_str()   ); }  string clearQuotes(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(\"[\\\"\\']\"), \"\").c_str()   ); }  string clearString(const string &amp;str) {   string clear_string = clearSpecSymbols(str);   clear_string = clearSpaces(clear_string);   clear_string = clearQuotes(clear_string);   clear_string = trim(clear_string);    return clear_string; }  string trim(const string &amp;str) {   if (str.empty()) {     return {};   }    size_t s = 0;   size_t e = str.size()-1;    while (s != e &amp;&amp; std::isspace(str[s])) {     s++;   }    while (e != s &amp;&amp; std::isspace(str[e])) {     e--;   }    return str.substr(s, (e-s)+1); }  \/* Example: #APP_NAME=Laravel *\/ bool isEnvComment(const string &amp;env_comment) {   return std::regex_match(     env_comment.c_str(),      std::regex(\"^#.*\", std::regex::ECMAScript)   ); }  \/* Example: APP_NAME *\/ bool isEnvVar(const string &amp;env_var) {   return std::regex_match(     env_var.c_str(),      std::regex(\"^[A-Z]+[A-Z\\\\W\\\\d_]*$\", std::regex::ECMAScript)   ); }  \/* Example: Laravel *\/ bool isEnvVal(const string &amp;env_val) {   return std::regex_match(     env_val.c_str(),      std::regex(\"(.*\\n(?=[A-Z])|.*$)\", std::regex::ECMAScript)   ); }  \/* Example: APP_NAME=Laravel -> APP_NAME *\/ string get_env_var(const string &amp;env_entry) {   string::size_type pos = env_entry.find_first_of(string(\"=\"), 0);    if (pos == string::npos) {     return {};   }    return env_entry.substr(0, pos); }  \/* Example: APP_NAME=Laravel -> Laravel *\/ string get_env_val(const string &amp;env_entry) {   string::size_type pos = env_entry.find_first_of(string(\"=\"), 0);    if (pos == string::npos) {     return {};   }    pos++;      return env_entry.substr(pos, env_entry.size() - pos); }  \/*  * \u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f parse_env_file  *\/ array&lt;string> f$parse_env_file(const string &amp;filename) {   if (filename.empty()) {     return {};   }    std::ifstream ifs(filename.c_str());    if (!ifs.is_open()) {     php_warning(\"File not open\");     return {};   }    array&lt;string> res(array_size(1, 0, true));    std::string env_entry;   while (getline(ifs, env_entry)) {     string env_entry_copy = clearString(string(env_entry.c_str()));      if (!env_entry_copy.empty() &amp;&amp; !isEnvComment(env_entry_copy)) {       string env_var = get_env_var(env_entry_copy);        if (env_var.empty()) {         php_warning(\"Invalid env string format %s\", env_entry_copy.c_str());         return {};       }        string env_val = get_env_val(env_entry_copy);        if (isEnvVar(env_var) &amp;&amp; isEnvVal(env_val)) {         res.set_value(env_var, env_val);       } else {         php_warning(\"Invalid env string format %s\", env_entry_copy.c_str());         return {};       }     }   }    ifs.close();    return res; }  \/*  * \u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f parse_env_string  *\/ array&lt;string> f$parse_env_string(const string &amp;env_string) {   if (env_string.empty()) {     return {};   }    array&lt;string> res(array_size(0, 0, true));    string env_string_copy = clearString(env_string);   env_string_copy = clearEOL(env_string_copy);    std::stringstream ss(env_string_copy.c_str());   std::string str;    while (getline(ss, str, ' ')) {     string env_entry = string(str.c_str());      if (!isEnvComment(env_entry)) {       string env_var = get_env_var(env_entry);        if (env_var.empty()) {         php_warning(\"Invalid env string format %s\", env_entry.c_str());         return {};       }        string env_val = get_env_val(env_entry);        if (isEnvVar(env_var) &amp;&amp; isEnvVal(env_val)) {         res.set_value(env_var, env_val);       } else {         php_warning(\"Invalid env string format %s\", env_entry.c_str());         return {};       }     }   }    return res; }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0432 runtime \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <strong>f$<\/strong> \u0432 \u043d\u0430\u0447\u0430\u043b\u0435. \u0418\u0431\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 (\u043f\u043e\u0437\u0436\u0435 \u0441\u0430\u043c\u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435). \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c, \u043f\u043b\u043e\u0434\u0438\u0442\u0435 \u043a\u043e\u0434\u0430 \u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \ud83d\ude42<\/p>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0434\u0432\u0443\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0432\u0435\u0449\u0430\u0445 &#8212; \u044d\u0442\u043e array&lt;string> \u0438 string. \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0441\u0442\u0440\u043e\u043a \u0432 \u0441\u0430\u043c\u043e\u043c runtime KPHP, \u0430 \u043d\u0435 std`\u0448\u043d\u0430\u044f (\u0421\u0430\u043c \u0431\u044b \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0421\u0442\u0435\u043f\u0430\u043d\u043e\u0432 \u0434\u0430\u043b \u0431\u044b \u043f\u043e \u0440\u0443\u043a\u0430\u043c \u0437\u0430 \u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u0430\u043a set_value \u0438 \u0434\u0440\u0443\u0433\u0438\u0435).<\/p>\n<p>array&lt;string> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b.<\/p>\n<p>string \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0432 int, float, bool, string.<\/p>\n<ol start=\"4\">\n<li>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0448 <strong>parsing_functions.cpp<\/strong> \u0432 cmake \u0444\u0430\u0439\u043b:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cmake\"># \u0442\u0443\u0442 \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e cmake   prepend(KPHP_RUNTIME_SOURCES ${BASE_DIR}\/runtime\/         ${KPHP_RUNTIME_DATETIME_SOURCES}         ${KPHP_RUNTIME_MEMORY_RESOURCE_SOURCES}         ${KPHP_RUNTIME_MSGPACK_SOURCES}         ${KPHP_RUNTIME_JOB_WORKERS_SOURCES}         ${KPHP_RUNTIME_SPL_SOURCES}         ${KPHP_RUNTIME_PDO_SOURCES}         ${KPHP_RUNTIME_PDO_MYSQL_SOURCES}         allocator.cpp         array_functions.cpp         bcmath.cpp         common_template_instantiations.cpp         confdata-functions.cpp         confdata-global-manager.cpp         confdata-keys.cpp         critical_section.cpp         curl.cpp         exception.cpp         files.cpp         from-json-processor.cpp         instance-cache.cpp         instance-copy-processor.cpp         inter-process-mutex.cpp         interface.cpp         json-functions.cpp         json-writer.cpp         kphp-backtrace.cpp         mail.cpp         math_functions.cpp         mbstring.cpp         memcache.cpp         memory_usage.cpp         migration_php8.cpp         misc.cpp         mixed.cpp         mysql.cpp         net_events.cpp         on_kphp_warning_callback.cpp         openssl.cpp         parsing_functions.cpp                            &lt;-- \u041d\u0430\u0448 \u0444\u0430\u0439\u043b         php_assert.cpp         profiler.cpp         regexp.cpp         resumable.cpp         rpc.cpp         serialize-functions.cpp         storage.cpp         streams.cpp         string.cpp         string_buffer.cpp         string_cache.cpp         string_functions.cpp         tl\/rpc_tl_query.cpp         tl\/rpc_response.cpp         tl\/rpc_server.cpp         typed_rpc.cpp         uber-h3.cpp         udp.cpp         url.cpp         vkext.cpp         vkext_stats.cpp         ffi.cpp         zlib.cpp         zstd.cpp)  # \u0438 \u0442\u0443\u0442 \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e cmake <\/code><\/pre>\n<p>\u0423\u0440\u0430! \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c.<\/p>\n<h4>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b<\/h4>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0438\u043a\u0442\u043e \u0436\u0435 \u043d\u0435 \u043f\u043e\u0432\u0435\u0440\u0438\u0442, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u044b&#8230; \u0418 \u043d\u0438\u043a\u0442\u043e \u0432\u0441\u0435\u0440\u044c\u0451\u0437 \u0432\u0430\u0441 \u043d\u0435 \u0432\u043e\u0441\u043f\u0440\u0438\u043c\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435 pull-request. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<p>\u0427\u0442\u043e \u043d\u0430\u0434\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u0442\u0435\u0441\u0442\u0430\u0445? <\/p>\n<pre><code class=\"bash\">kphp\/ \u251c\u2500 tests\/ \u2502  \u251c\u2500 cpp\/                        &lt;---- \u0417\u0434\u0435\u0441\u044c cpp \u0442\u0435\u0441\u0442\u044b  \u2502  \u2502  \u251c\u2500 compiler                 &lt;---- \u0422\u0435\u0441\u0442\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u2502  \u2502  \u251c\u2500 runtime                  &lt;---- \u0422\u0435\u0441\u0442\u044b runtime \u2502  \u2502  \u2502   \u251c\u2500 *.cpp                1) \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c cpp \u0444\u0430\u0439\u043b\u044b \u0442\u0435\u0441\u0442\u043e\u0432 \u2502  \u2502  \u2502   \u251c\u2500 runtime-tests.cmake  2) \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043c \u0438\u043c\u0435\u043d\u0430 cpp \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e RUNTIME_TESTS_SOURCES \u2502  \u2502  \u251c\u2500 server                   &lt;---- \u0422\u0435\u0441\u0442\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u2502  \u251c\u2500 phpt\/                       &lt;---- \u0417\u0434\u0435\u0441\u044c php \u0442\u0435\u0441\u0442\u044b \u2502  \u2502  \u251c\u2500 my_folder_with_tests     3) \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u044e \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 |  |  |   \u251c\u2500 001_*.php            4) \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u0438 *.php \u0442\u0435\u0441\u0442\u044b \u0441 \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0435\u0439 |  \u251c\u2500 kphp_tester.py              5) \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/code><\/pre>\n<p>CPP \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e gtest \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 unit-\u0442\u0435\u0441\u0442\u0430\u043c\u0438. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, php \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041f\u0438\u0448\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u043d\u0430 php, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e kphp. \u0417\u0430\u0442\u0435\u043c \u043e\u043d\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>kphp_tester.py<\/strong> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 php \u043a\u043e\u0434, \u0442\u0430\u043a \u0438 kphp. \u0417\u0430\u0442\u0435\u043c \u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434, \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u043d \u0438\u043b\u0438 \u043d\u0435\u0442. <\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441 \u0432\u043e\u0442 \u0432 \u0447\u0451\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 php \u0443\u0437\u043d\u0430\u0435\u0442 \u043e \u0442\u043e\u0439 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>parse_env_string<\/strong> \u0438 <strong>parse_env_file<\/strong>, \u0435\u0441\u043b\u0438 \u0438\u0445 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435\u0442? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u044b php-polyfills (\u0432 \u0441\u0432\u043e\u0451\u043c \u0440\u043e\u0434\u0435 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438). \u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0451 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u0430\u043c\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 cpp \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"bash\"># \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 build cd build  # \u0421\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0441\u0451 \u0435\u0449\u0451 \u0440\u0430\u0437 make -j6 all  # \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442\u044b ctest -j6<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 php \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"bash\"># \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u0430\u0447\u0430\u0442\u044c php-polyfiils git clone https:\/\/github.com\/VKCOM\/kphp-polyfills.git  # \u0417\u0430\u0439\u0434\u0451\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 kphp-polyfiils cd kphp-polyfills  # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c autoload  composer install  # \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f KPHP_TESTS_POLYFIILS_REPO  export KPHP_TESTS_POLYFILLS_REPO=$(pwd)<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0430\u044f \u043c\u043d\u043e\u0433\u043e\u0445\u043e\u0434\u043e\u0432\u043e\u0447\u043a\u0430 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 php \u0442\u0435\u0441\u0442\u043e\u0432, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c &#171;\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438&#187;.<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 php \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"bash\"># \u0417\u0430\u043f\u0443\u0441\u043a \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 tests\/kphp_tester.py  # \u0417\u0430\u043f\u0443\u0441\u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 tests\/kphp_tester.py 001_*.php<\/code><\/pre>\n<p>\u0412\u0443\u0430\u043b\u044f! <\/p>\n<h3>CPP \u0442\u0435\u0441\u0442\u044b<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a \u043d\u0430\u0448\u0438\u043c \u0431\u0430\u0440\u0430\u0448\u043a\u0430\u043c (\u043a f$parse_env_string \u0438 f$parse_env_file). \u0414\u043e\u0431\u0430\u0432\u0438\u043c parsing-functions-tests.cpp \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">#include &lt;gtest\/gtest.h> #include \"runtime\/parsing_functions.h\"  TEST(parsing_functions_test, test_isEnvComment) {   ASSERT_FALSE(isEnvComment(string(\"\")));   ASSERT_FALSE(isEnvComment(string(\"APP_NAME=Laravel\")));   ASSERT_TRUE(isEnvComment(string(\"#APP_NAME=Laravel\"))); }  TEST(parsing_functions_test, test_isEnvVar) {   ASSERT_FALSE(isEnvVar(string(\"\")));   ASSERT_FALSE(isEnvVar(string(\"!APP_NAME\")));   ASSERT_TRUE(isEnvVar(string(\"APP_NAME\"))); }  TEST(parsing_functions_test, test_isEnvVal) {   ASSERT_TRUE(isEnvVal(string(\"\")));   ASSERT_TRUE(isEnvVal(string(\"true\")));   ASSERT_TRUE(isEnvVal(string(\"local\")));   ASSERT_TRUE(isEnvVal(string(\"80\")));   ASSERT_TRUE(isEnvVal(string(\"127.0.0.1\")));   ASSERT_TRUE(isEnvVal(string(\"https:\/\/localhost\")));   ASSERT_TRUE(isEnvVal(string(\"\\'This is my env val\\'\")));   ASSERT_TRUE(isEnvVal(string(\"\\\"This is my env val\\\"\"))); }  TEST(parsing_functions_test, test_get_env_var) {   string str(\"APP_NAME=Laravel\");   string env_var = get_env_var(str);    ASSERT_STREQ(string(\"\").c_str(), get_env_var(string(\"\")).c_str());   ASSERT_STREQ(\"APP_NAME\", env_var.c_str());   ASSERT_EQ(strlen(\"APP_NAME\"), env_var.size()); }  TEST(parsing_functions_test, test_get_env_val) {   string str(\"APP_NAME=Laravel\");   string env_val = get_env_val(str);    ASSERT_STREQ(\"Laravel\", env_val.c_str());   ASSERT_EQ(string(\"Laravel\").size(), env_val.size()); }  \/*  * \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e parse_env_string  *\/ TEST(parsing_functions_test, test_parse_env_string) {   string env_string = string(R\"(APP_NAME=Laravel APP_ENV=local #APP_KEY=base64:mtlb8hldh5hZ0GlLzbhInsV531MSylspRI4JsmwVal8= APP_DEBUG=true T1=\"my\" T2='my')\");    array&lt;string> res(array_size(0, 0, true));    res = f$parse_env_string(env_string);   ASSERT_EQ(res.size().string_size, 5);    ASSERT_TRUE(res.has_key(string(\"APP_NAME\")));   ASSERT_STREQ(res.get_value(string(\"APP_NAME\")).c_str(), string(\"Laravel\").c_str());   ASSERT_TRUE(res.has_key(string(\"APP_ENV\")));   ASSERT_STREQ(res.get_value(string(\"APP_ENV\")).c_str(), string(\"local\").c_str());   ASSERT_TRUE(res.has_key(string(\"APP_DEBUG\")));   ASSERT_STREQ(res.get_value(string(\"APP_DEBUG\")).c_str(), string(\"true\").c_str());   ASSERT_TRUE(res.has_key(string(\"T1\")));   ASSERT_STREQ(res.get_value(string(\"T1\")).c_str(), string(\"my\").c_str());   ASSERT_TRUE(res.has_key(string(\"T2\")));   ASSERT_STREQ(res.get_value(string(\"T2\")).c_str(), string(\"my\").c_str()); }  \/*  * \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e parse_env_file  *\/ TEST(parsing_functions_test, test_parse_env_file) {   std::ofstream of(\".env.example\");    if (of.is_open()) {     of &lt;&lt; \"APP_NAME=Laravel \"&lt;&lt; std::endl;     of &lt;&lt; \"APP_ENV=local\" &lt;&lt; std::endl;     of &lt;&lt; \"APP_DEBUG=true\" &lt;&lt; std::endl;     of.close();   }    array&lt;string> res(array_size(0, 0, true));    res = f$parse_env_file(string(\"file not found\"));   ASSERT_EQ(res.size().string_size, 0);    res = f$parse_env_file(string(\".env.example\"));   ASSERT_TRUE(res.has_key(string(\"APP_NAME\")));   ASSERT_STREQ(res.get_value(string(\"APP_NAME\")).c_str(), string(\"Laravel\").c_str());   ASSERT_TRUE(res.has_key(string(\"APP_ENV\")));   ASSERT_STREQ(res.get_value(string(\"APP_ENV\")).c_str(), string(\"local\").c_str());   ASSERT_TRUE(res.has_key(string(\"APP_DEBUG\")));   ASSERT_STREQ(res.get_value(string(\"APP_DEBUG\")).c_str(), string(\"true\").c_str()); } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e  \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b36\/fc5\/a83\/b36fc5a8398d2c86efd9c91e411b4922.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b cpp \u0442\u0435\u0441\u0442\u043e\u0432\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b cpp \u0442\u0435\u0441\u0442\u043e\u0432\" width=\"939\" height=\"310\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b36\/fc5\/a83\/b36fc5a8398d2c86efd9c91e411b4922.png\"\/><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b cpp \u0442\u0435\u0441\u0442\u043e\u0432<\/figcaption><\/figure>\n<h3>PHP \u0442\u0435\u0441\u0442\u044b<\/h3>\n<p>\u0412\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043f\u0440\u043e php-polyfills, \u0438\u0434\u0451\u043c \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0432 \u043a\u043e\u0440\u043d\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0444\u0430\u0439\u043b <strong>kphp_polyfiils.php<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">#ifndef KPHP  # \u0442\u0443\u0442 \u043c\u043d\u043e\u0433\u043e \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043a\u043e\u0434\u0430  #region env parsing  \/**  * parse_env_string return associative array by parsed string  *   *\/ function parse_env_string(string $env_string) {   if (empty($env_string)) {     return [];   }    $get_env_entry = function ($env_string) {     $env_entry = explode('=', $env_string, 2);      if (count($env_entry) !== 2) {       die(\"parse error\\n\");     }      return [       'env_var' => trim($env_entry[0]),       'env_val' => trim($env_entry[1])     ];   };    $lines = explode(' ', $env_string);   $env = [];     foreach ($lines as $line) {     $env_entry = $get_env_entry($line);      $env[trim($env_entry['env_var'])] = trim($env_entry['env_val']);    }    return $env; }  \/**  * parse_env_string return associative array by parsed file  *   *\/ function parse_env_file(string $filename) {    if (empty($filename)) {     return [];   }    if (!is_file($filename)) {     return [];   }    if (!file_exists($filename)) {     return [];   }    $env_string = file_get_contents($filename);    return parse_env_string($env_string); }  #endregion  #endif<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 env \u0441\u0442\u0440\u043e\u043a \u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ENV. \u0427\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0432 \u0434\u0430\u0436\u0435 \u0446\u0435\u043b\u0443\u044e <a href=\"https:\/\/github.com\/pmswga\/kenv\" rel=\"noopener noreferrer nofollow\">\u043b\u0438\u0431\u0443<\/a> (kenv).<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e \u043f\u0443\u0442\u0438 <strong>tests\/phpt\/parsing\/001_parsing_env.php<\/strong> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"php\">@ok                                              # &lt;-- \u0422\u0435\u0433 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 KPHP &lt;?php  require_once 'kphp_tester_include.php';          # &lt;-- \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c php-polyfills  function test_parse_env_string_empty() {         # &lt;-- \u0421\u0430\u043c\u0438 \"\u0442\u0435\u0441\u0442\u044b\"     var_dump(parse_env_string('')); }  function test_parse_env_string_one() {     var_dump(parse_env_string('APP_NAME=Laravel')); }  function test_parse_env_string_many() {     var_dump(parse_env_string('APP_NAME=Laravel APP_DEBUG=true APP_ENV=local')); }  function test_parse_env_file_empty() {     var_dump(parse_env_file('')); }  function test_parse_env_file_not_found_empty() {     var_dump(parse_env_file('file not found')); }  function test_parse_env_file_one() {     $filename = tempnam(\"\", \"wt\");     $fp = fopen($filename, \"a\");     fwrite($fp, \"APP_NAME=Laravel\");     fclose($fp);      var_dump(parse_env_file($filename)); }  function test_parse_env_file_many() {     $filename = tempnam(\"\", \"wt\");     $fp = fopen($filename, \"a\");     fwrite($fp, \"APP_NAME=Laravel\");     fwrite($fp, \"APP_DEBUG=true\");     fwrite($fp, \"APP_ENV=local\");     fclose($fp);      var_dump(parse_env_file($filename)); }  test_parse_env_string_empty();                   # &lt;-- \u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 test_parse_env_string_one(); test_parse_env_string_many();  test_parse_env_file_empty(); test_parse_env_file_not_found_empty(); test_parse_env_file_one(); test_parse_env_file_many();<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442:  <\/p>\n<pre><code class=\"bash\">tests\/kphp_tester.py 001_parse_env<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442, \u0437\u0430\u0432\u0435\u0442\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e passed. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7f9\/d1d\/c4a\/7f9d1dc4af86a46e5e60d696b6866603.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b php \u0442\u0435\u0441\u0442\u043e\u0432\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b php \u0442\u0435\u0441\u0442\u043e\u0432\" width=\"1029\" height=\"129\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7f9\/d1d\/c4a\/7f9d1dc4af86a46e5e60d696b6866603.png\"\/><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b php \u0442\u0435\u0441\u0442\u043e\u0432<\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c<\/p>\n<p>\u0418\u0442\u043e\u0433\u043e, \u0432\u043e\u0442 \u043a\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u044b \u0432\u043d\u0435\u0441\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>parse_env_file<\/strong> \u0438 <strong>parse_env_string<\/strong>. <\/p>\n<pre><code># \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 kphp kphp\/ \u251c\u2500 builin-functions\/_functions.txt       &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b parse_env_file \u0438 parse_env_string \u251c\u2500 runtime\/ \u2502  \u251c\u2500 parsing_functions.h                &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439  \u2502  \u251c\u2500 parsing_functions.cpp              &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2502  \u251c\u2500 runtime.cmake                      &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 parsing_functions.cpp \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e KPHP_RUNTIME_SOURCES \u251c\u2500 tests\/ \u2502  \u251c\u2500 cpp\/ \u2502  \u2502  \u251c\u2500 runtime \u2502  \u2502  \u2502   \u251c\u2500 parsing-functions-tests.cpp &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 cpp \u0442\u0435\u0441\u0442\u044b \u2502  \u2502  \u2502   \u251c\u2500 runtime-tests.cmake         &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 parsing-functions-tests.cpp \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e RUNTIME_TESTS_SOURCES \u2502  \u251c\u2500 phpt\/ \u2502  \u2502  \u251c\u2500 parsing                         &lt;-- \u0421\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0430\u043f\u043a\u0443 parsing |  |  |   \u251c\u2500 001_parse_env.php           &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 php \u0442\u0435\u0441\u0442\u044b  # \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 kphp-polyfills kphp-polyfills\/ \u251c\u2500 kphp_polyfills.php                    &lt;-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 php`\u0448\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 parse_env_file \u0438 parse_env_string<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043d\u0430\u0448\u0438 \u043f\u043b\u043e\u0434\u044b. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c <strong>index.php<\/strong> \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"php\">&lt;?php     $env_string = \"APP_NAME=Laravel APP_DEBUG=true APP_ENV=local\";      $res = parse_env_string($env_string);      print_r('&lt;pre>');     print_r($res);     print_r('&lt;\/pre>');      $res = parse_env_file('.env.example');      print_r('&lt;pre>');     print_r($res);     print_r('&lt;\/pre>');<\/code><\/pre>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e:  <\/p>\n<pre><code class=\"bash\">.\/kphp2cpp index.php<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"bash\">.\/kphp_out\/server -H 8000 -f 2                    ^       ^                    |       |                    |     \u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u0434\u0432\u0443\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c                    |                  \u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c localhost:8000<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/945\/098\/236\/9450982369f43066d00dc550680ce6ac.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e index.php\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e index.php\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/945\/098\/236\/9450982369f43066d00dc550680ce6ac.png\"\/><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e index.php<\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u0447\u0442\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0421++:  <\/p>\n<pre><code class=\"cpp\">\/\/crc64:912a10e8beed9098 \/\/crc64_with_comments:bc9f187534f26ce2 #include \"runtime-headers.h\" #include \"o_6\/src_indexbccbb8a09559268e.h\" extern string v$env_string;  extern array&lt; string > v$res;  extern bool v$src_indexbccbb8a09559268e$called;  extern string v$const_string$us3e8066aa5eeccc54;  extern string v$const_string$us531c70314bd2d991;  extern string v$const_string$usd04f12c090cf2e22;  extern string v$const_string$use301963cf43e4d3a;  \/\/source = [index.php] \/\/3:     $env_string = \"APP_NAME=Laravel APP_DEBUG=true APP_ENV=local\"; Optional &lt; bool > f$src_indexbccbb8a09559268e() noexcept  {   v$src_indexbccbb8a09559268e$called = true;   v$env_string = v$const_string$us3e8066aa5eeccc54; \/\/4:  \/\/5:     $res = parse_env_string($env_string);   v$res = f$parse_env_string(v$env_string);                       &lt;-- \u0412\u043e\u0442 \u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438  \/\/6:  \/\/7: print_r('&lt;pre>');   f$print_r(v$const_string$usd04f12c090cf2e22); \/\/8:     print_r($res);   f$print_r(v$res); \/\/9: print_r('&lt;\/pre>');   f$print_r(v$const_string$us531c70314bd2d991); \/\/10:  \/\/11:  \/\/12:     $res = parse_env_file('.env.example');   v$res = f$parse_env_file(v$const_string$use301963cf43e4d3a);    &lt;-- \u0418 \u0432\u043e\u0442 \u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438   \/\/13:  \/\/14: print_r('&lt;pre>');   f$print_r(v$const_string$usd04f12c090cf2e22); \/\/15:     print_r($res);   f$print_r(v$res); \/\/16:    f$print_r(v$const_string$us531c70314bd2d991);   return Optional&lt;bool>{}; }<\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0441\u0435\u043c \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 KPHP, \u0442\u043e \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 <a href=\"https:\/\/t.me\/kphp_chat\" rel=\"noopener noreferrer nofollow\">\u0447\u0430\u0442<\/a>.<\/p>\n<p>\u041f\u043e \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-internals\/developing-and-extending-kphp\/compiling-kphp-from-sources.html\" rel=\"noopener noreferrer nofollow\">\u0421\u0431\u043e\u0440\u043a\u0430 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-internals\/kphp-architecture\/internals-runtime.html\" rel=\"noopener noreferrer nofollow\">runtime kphp<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-internals\/developing-and-extending-kphp\/contributing-to-kphp.html\" rel=\"noopener noreferrer nofollow\">contributing to kphp<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-internals\/developing-and-extending-kphp\/writing-and-running-tests.html\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/\" rel=\"noopener noreferrer nofollow\"><u>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 vk.com\/kphp<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e KPHP<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/VKCOM\" rel=\"noopener noreferrer nofollow\">\u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b VK<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/701216\/\"> https:\/\/habr.com\/ru\/post\/701216\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0434\u043d\u044f, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 runtime KPHP.<\/p>\n<p>\u0421\u043e\u0432\u0441\u0435\u043c \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 KPHP \u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 runtime KPHP.<\/p>\n<h3>\u041e KPHP<\/h3>\n<p>KPHP &#8212; \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 PHP. \u0414\u0435-\u0444\u0430\u043a\u0442\u043e PHP, \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 C++. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<h3>\u041e \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435<\/h3>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0440\u0435\u0448\u0438\u043c, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0441\u0442\u0440\u043e\u043a \u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ENV. \u0418\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 runtime.<\/p>\n<h3>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u043b\u0430\u043d\u0443:<\/p>\n<ol start=\"NaN\">\n<li>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<\/ol>\n<h4>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435<\/h4>\n<p>\u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043f\u043e\u0434 Ubuntu 20.04. \u0418 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 (\u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0438\u0445 \u043d\u0435\u0442):<\/p>\n<ul>\n<li>\n<p>git<\/p>\n<\/li>\n<li>\n<p>make, cmake<\/p>\n<\/li>\n<li>\n<p>g++,<\/p>\n<\/li>\n<li>\n<p>python3,<\/p>\n<\/li>\n<li>\n<p>pip3<\/p>\n<\/li>\n<li>\n<p>php7.4<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c vk`\u0448\u043d\u044b\u0435. \u0410 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438:<\/p>\n<pre><code class=\"bash\">sudo apt-get update  sudo apt-get install -y --no-install-recommends apt-utils ca-certificates gnupg wget  sudo wget -qO - https:\/\/repo.vkpartner.ru\/GPG-KEY.pub | sudo apt-key add -  echo \"deb https:\/\/repo.vkpartner.ru\/kphp-focal\/ focal main\" >> \/etc\/apt\/sources.list<\/code><\/pre>\n<p>\u0418 \u0443\u0436\u0435 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b:  <\/p>\n<pre><code class=\"bash\">sudo apt-get update  sudo apt install git cmake make g++ gperf python3-minimal python3-jsonschema \\             curl-kphp-vk libuber-h3-dev kphp-timelib libfmt-dev libgtest-dev libgmock-dev libre2-dev libpcre3-dev \\             libzstd-dev libyaml-cpp-dev libnghttp2-dev zlib1g-dev php7.4-dev libmysqlclient-dev libnuma-dev<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0434\u0435\u043b\u0430\u0432 \u044d\u0442\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u0431\u043e\u0440\u043a\u0435 KPHP \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432:<\/p>\n<pre><code class=\"bash\"># \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 git clone https:\/\/github.com\/VKCOM\/kphp.git  # \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f cd kphp  # \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0432\u0435\u0442\u043a\u0443 git checkout -b 'pmswga\/env_parsing'  # \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u043f\u043a\u0443 build mkdir build  # \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 build cd build  # \u041f\u0440\u043e\u0441\u0438\u043c cmake \u043f\u043e CMakeLists.txt \u0441\u043e\u0442\u043e\u0432\u0440\u0438\u0442\u044c \u043d\u0430\u043c \u0447\u0443\u0434\u043e cmake ..  # \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0438\u043c make \u0441\u043e\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0447\u0443\u0434\u043e  make -j6 all<\/code><\/pre>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u043e\u0439\u0442\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0427\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u0438\u0442\u043e\u0433\u0435? \u0412 \u043a\u043e\u0440\u043d\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 objs \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0440\u0438 \u043d\u0435\u0439:  <\/p>\n<pre><code class=\"bash\">kphp\/ \u251c\u2500 build\/                      &lt;-- \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0438, \u0442\u043e \u0432\u044b \u0442\u0443\u0442 :) \u251c\u2500 objs\/ \u2502  \u251c\u2500 bin\/ \u2502  \u2502  \u251c\u2500 kphp2cpp              &lt;-- \u041d\u0430\u0448 kphp \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 :( \u2502  \u2502  \u251c\u2500 tl2php \u2502  \u2502  \u251c\u2500 tl-compiler \u2502  \u251c\u2500 flex\/ \u2502  \u2502  \u251c\u2500 libvk-flex-data.o \u2502  \u2502  \u251c\u2500 libvk-flex-data.so \u2502  \u251c\u2500 generated\/* \u2502  \u251c\u2500 vkext\/ \u2502  \u2502  \u251c\u2500 modules\/ \u2502  \u2502  \u2502  \u251c\u2500 vkext.so \u2502  \u2502  \u251c\u2500 modules7.4\/ \u2502  \u2502  \u2502  \u251c\u2500 vkext.so<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043c\u044b \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e KPHP \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432. \u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u044b, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<h4>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e \u043e\u0431\u0440\u0438\u0441\u0443\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<pre><code class=\"bash\">kphp\/ \u251c\u2500 builin-functions\/_functions.txt  1) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u044e\u0434\u0430 \u251c\u2500 runtime\/ \u2502  \u251c\u2500 *.h                           2) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c h-\u0444\u0430\u0439\u043b\u044b \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0439  \u2502  \u251c\u2500 *.cpp                         3) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c cpp-\u0444\u0430\u0439\u043b\u044b \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2502  \u251c\u2500 runtime.cmake                 4) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 cpp-\u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e KPHP_RUNTIME_SOURCES<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c make \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0451 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ol start=\"NaN\">\n<li>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 _functions.txt \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <strong>parse_env_file<\/strong> \u0438 <strong>parse_env_string<\/strong>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043d\u0430 \u0442\u043e \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u044b. \u0412 \u0446\u0435\u043b\u043e\u043c \u0432\u0441\u0451 \u044f\u0441\u043d\u043e. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0442\u0440\u043e\u043a.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"go\">function parse_env_file($filename ::: string) ::: string[]; function parse_env_string($env_string ::: string) ::: string[];<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <strong>parsing_functions.h<\/strong> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">#pragma once  #include \"runtime\/kphp_core.h\" #include &lt;regex> #include &lt;fstream> #include &lt;sstream>  \/*  * Cool functions. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0441\u0442\u0440\u043e\u043a \u043e\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0433\u043e  *\/  string clearSpecSymbols(const string &amp;str);  string clearSpaces(const string &amp;str);  string clearEOL(const string &amp;str);  string clearQuotes(const string &amp;str);  string clearString(const string &amp;str);  string trim(const string &amp;str);  \/*  * The best funtions.   * \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c   * \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0447\u0430\u0441\u0442\u0438 \u043e\u0434\u043d\u043e\u0439 ENV-\u0437\u0430\u043f\u0438\u0441\u0438  *\/  bool isEnvComment(const string &amp;env_comment);  bool isEnvVar(const string &amp;env_var);  bool isEnvVal(const string &amp;env_val);  string get_env_var(const string &amp;env_entry);  string get_env_val(const string &amp;env_entry);  \/*  * Env file|string parsing functions.   * \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435  *\/  array&lt;string> f$parse_env_file(const string &amp;filename);  array&lt;string> f$parse_env_string(const string &amp;env_string);<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 <strong>parsing_functions.cpp<\/strong> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">#include \"parsing_functions.h\"  string clearSpecSymbols(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(R\"([\\t\\r\\b\\v])\"), \"\").c_str()   ); }  string clearSpaces(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(\" += +\"), \"=\").c_str()   ); }  string clearEOL(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(\"\\\\n\"), \" \").c_str()   ); }  string clearQuotes(const string &amp;str) {   return string(     std::regex_replace(str.c_str(), std::regex(\"[\\\"\\']\"), \"\").c_str()   ); }  string clearString(const string &amp;str) {   string clear_string = clearSpecSymbols(str);   clear_string = clearSpaces(clear_string);   clear_string = clearQuotes(clear_string);   clear_string = trim(clear_string);    return clear_string; }  string trim(const string &amp;str) {   if (str.empty()) {     return {};   }    size_t s = 0;   size_t e = str.size()-1;    while (s != e &amp;&amp; std::isspace(str[s])) {     s++;   }    while (e != s &amp;&amp; std::isspace(str[e])) {     e--;   }    return str.substr(s, (e-s)+1); }  \/* Example: #APP_NAME=Laravel *\/ bool isEnvComment(const string &amp;env_comment) {   return std::regex_match(     env_comment.c_str(),      std::regex(\"^#.*\", std::regex::ECMAScript)   ); }  \/* Example: APP_NAME *\/ bool isEnvVar(const string &amp;env_var) {   return std::regex_match(     env_var.c_str(),      std::regex(\"^[A-Z]+[A-Z\\\\W\\\\d_]*$\", std::regex::ECMAScript)   ); }  \/* Example: Laravel *\/ bool isEnvVal(const string &amp;env_val) {   return std::regex_match(     env_val.c_str(),      std::regex(\"(.*\\n(?=[A-Z])|.*$)\", std::regex::ECMAScript)   ); }  \/* Example: APP_NAME=Laravel -> APP_NAME *\/ string get_env_var(const string &amp;env_entry) {   string::size_type pos = env_entry.find_first_of(string(\"=\"), 0);    if (pos == string::npos) {     return {};   }    return env_entry.substr(0, pos); }  \/* Example: APP_NAME=Laravel -> Laravel *\/ string get_env_val(const string &amp;env_entry) {   string::size_type pos = env_entry.find_first_of(string(\"=\"), 0);    if (pos == string::npos) {     return {};   }    pos++;      return env_entry.substr(pos, env_entry.size() - pos); }  \/*  * \u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f parse_env_file  *\/ array&lt;string> f$parse_env_file(const string &amp;filename) {   if (filename.empty()) {     return {};   }    std::ifstream ifs(filename.c_str());    if (!ifs.is_open()) {     php_warning(\"File not open\");     return {};   }    array&lt;string> res(array_size(1, 0, true));    std::string env_entry;   while (getline(ifs, env_entry)) {     string env_entry_copy = clearString(string(env_entry.c_str()));      if (!env_entry_copy.empty() &amp;&amp; !isEnvComment(env_entry_copy)) {       string env_var = get_env_var(env_entry_copy);        if (env_var.empty()) {         php_warning(\"Invalid env string format %s\", env_entry_copy.c_str());         return {};       }        string env_val = get_env_val(env_entry_copy);        if (isEnvVar(env_var) &amp;&amp; isEnvVal(env_val)) {         res.set_value(env_var, env_val);       } else {         php_warning(\"Invalid env string format %s\", env_entry_copy.c_str());         return {};       }     }   }    ifs.close();    return res; }  \/*  * \u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f parse_env_string  *\/ array&lt;string> f$parse_env_string(const string &amp;env_string) {   if (env_string.empty()) {     return {};   }    array&lt;string> res(array_size(0, 0, true));    string env_string_copy = clearString(env_string);   env_string_copy = clearEOL(env_string_copy);    std::stringstream ss(env_string_copy.c_str());   std::string str;    while (getline(ss, str, ' ')) {     string env_entry = string(str.c_str());      if (!isEnvComment(env_entry)) {       string env_var = get_env_var(env_entry);        if (env_var.empty()) {         php_warning(\"Invalid env string format %s\", env_entry.c_str());         return {};       }        string env_val = get_env_val(env_entry);        if (isEnvVar(env_var) &amp;&amp; isEnvVal(env_val)) {         res.set_value(env_var, env_val);       } else {         php_warning(\"Invalid env string format %s\", env_entry.c_str());         return {};       }     }   }    return res; }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0432 runtime \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <strong>f$<\/strong> \u0432 \u043d\u0430\u0447\u0430\u043b\u0435. \u0418\u0431\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 (\u043f\u043e\u0437\u0436\u0435 \u0441\u0430\u043c\u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435). \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c, \u043f\u043b\u043e\u0434\u0438\u0442\u0435 \u043a\u043e\u0434\u0430 \u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \ud83d\ude42<\/p>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0434\u0432\u0443\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0432\u0435\u0449\u0430\u0445 &#8212; \u044d\u0442\u043e array&lt;string> \u0438 string. \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0441\u0442\u0440\u043e\u043a \u0432 \u0441\u0430\u043c\u043e\u043c runtime KPHP, \u0430 \u043d\u0435 std`\u0448\u043d\u0430\u044f (\u0421\u0430\u043c \u0431\u044b \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0421\u0442\u0435\u043f\u0430\u043d\u043e\u0432 \u0434\u0430\u043b \u0431\u044b \u043f\u043e \u0440\u0443\u043a\u0430\u043c \u0437\u0430 \u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u0430\u043a set_value \u0438 \u0434\u0440\u0443\u0433\u0438\u0435).<\/p>\n<p>array&lt;string> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b.<\/p>\n<p>string \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0432 int, float, bool, string.<\/p>\n<ol start=\"4\">\n<li>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0448 <strong>parsing_functions.cpp<\/strong> \u0432 cmake \u0444\u0430\u0439\u043b:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cmake\"># \u0442\u0443\u0442 \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e cmake   prepend(KPHP_RUNTIME_SOURCES ${BASE_DIR}\/runtime\/         ${KPHP_RUNTIME_DATETIME_SOURCES}         ${KPHP_RUNTIME_MEMORY_RESOURCE_SOURCES}         ${KPHP_RUNTIME_MSGPACK_SOURCES}         ${KPHP_RUNTIME_JOB_WORKERS_SOURCES}         ${KPHP_RUNTIME_SPL_SOURCES}         ${KPHP_RUNTIME_PDO_SOURCES}         ${KPHP_RUNTIME_PDO_MYSQL_SOURCES}         allocator.cpp         array_functions.cpp         bcmath.cpp         common_template_instantiations.cpp         confdata-functions.cpp<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-341696","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341696"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341696\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}