{"id":304613,"date":"2020-06-01T03:00:27","date_gmt":"2020-06-01T03:00:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304613"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304613","title":{"rendered":"\u0421\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u0434\u043b\u044f PHP"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504720\/\">\u0412\u044b\u0431\u0438\u0440\u0430\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/github.com\/gotzmann\/comet\" rel=\"nofollow\">Comet<\/a>, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432 PHP-\u043a\u043e\u043c\u043c\u044c\u044e\u043d\u0438\u0442\u0438 \u0434\u0432\u0438\u0436\u043a\u0438. \u041e\u0431\u044b\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u0438\u043a\u0442\u0443\u0435\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a: \u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0441\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u0442 \u0432 Twig, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 Laravel \u0432\u043e\u043e\u0440\u0443\u0436\u0438\u0442\u0441\u044f Blade. \u041d\u043e \u043c\u0435\u043d\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u043a\u0430\u043a \u044d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438? \u041f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u043c\u0438 \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u0438 \u0447\u0438\u0441\u0442\u043e\u0433\u043e PHP \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043e\u0442\u0432\u0435\u0442. \u0414\u0430\u043d\u043d\u044b\u0435, \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u044b \u0438 \u043b\u0443\u0437\u0435\u0440\u044b \u2014 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a6\/l3\/n5\/a6l3n5qvorltm0fyii7l_xjtrsw.jpeg\"><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418\u043c\u0435\u043d\u0430 \u0442\u043e\u043f\u043e\u0432\u044b\u0445 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0435\u043d\u0442\u043e\u0432 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u0441\u0430\u043c, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0448\u0435\u043b, \u0432\u043e\u043e\u0440\u0443\u0436\u0438\u0432\u0448\u0438\u0441\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u043e\u0439 GitHub \u0438 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 Reddit. \u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f:<\/p>\n<p>  Smarty: <a href=\"https:\/\/github.com\/smarty-php\/smarty\" rel=\"nofollow\">github.com\/smarty-php\/smarty<\/a><br \/>  Plates: <a href=\"https:\/\/github.com\/thephpleague\/plates\" rel=\"nofollow\">github.com\/thephpleague\/plates<\/a><br \/>  Mustache: <a href=\"https:\/\/github.com\/bobthecow\/mustache.php\" rel=\"nofollow\">github.com\/bobthecow\/mustache.php<\/a><br \/>  Twig: <a href=\"https:\/\/github.com\/twigphp\/Twig\" rel=\"nofollow\">github.com\/twigphp\/Twig<\/a><br \/>  Blade: <a href=\"https:\/\/github.com\/jenssegers\/blade\" rel=\"nofollow\">github.com\/jenssegers\/blade<\/a><br \/>  BladeOne: <a href=\"https:\/\/github.com\/EFTEC\/BladeOne\" rel=\"nofollow\">github.com\/EFTEC\/BladeOne<\/a><br \/>  Latte: <a href=\"https:\/\/github.com\/nette\/latte\" rel=\"nofollow\">github.com\/nette\/latte<\/a><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0435\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u043f\u0438\u0448\u0438\u0442\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0432 \u0442\u0435\u0441\u0442. Blade \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0432 Laravel, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u0437\u044f\u0442\u044c \u043f\u0430\u0440\u0443 \u0435\u0433\u043e standalone-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b Blade-X.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0443\u0442\u044c \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0430, \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044e \u043a\u043e\u0434\u0430 \u0441 \u0447\u0438\u0441\u0442\u044b\u043c PHP:<\/p>\n<pre><code class=\"php\">$data = [      (object) [     &quot;code&quot; =&gt; 200,      &quot;message&quot; =&gt; &quot;OK&quot;     ],     (object) [         &quot;code&quot; =&gt; 404,          &quot;message&quot; =&gt; &quot;Not Found&quot;     ],     (object) [         &quot;code&quot; =&gt; 500,          &quot;message&quot; =&gt; &quot;Internal Server Error&quot;     ],\t\t  ];  $html = '&lt;html&gt;&lt;head&gt;&lt;\/head&gt;&lt;body&gt;'; foreach ($data as $message) {     $html .= &quot;&lt;p&gt;$message-&gt;code : $message-&gt;message&lt;\/p&gt;&quot;; } $html .= '&lt;\/body&gt;&lt;\/html&gt;'; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0435\u0441\u0442 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 HTML-\u0448\u0430\u0431\u043b\u043e\u043d \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: HTML-\u043a\u043e\u0434 \u0438 \u0435\u0433\u043e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.<\/p>\n<p>  \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0430\u043d\u0430\u043b\u043e\u0433 \u043d\u0430 Twig:<\/p>\n<pre><code class=\"php\">&lt;html&gt;&lt;head&gt;&lt;\/head&gt;&lt;body&gt;      {% for message in data %}         &lt;p&gt;{{ message.code }} : {{ message.message }}&lt;\/p&gt;     {% endfor %}  &lt;\/body&gt;&lt;\/html&gt; <\/code><\/pre>\n<p>  \u0410 \u044d\u0442\u043e Blade:<\/p>\n<pre><code class=\"php\">&lt;html&gt;&lt;head&gt;&lt;\/head&gt;&lt;body&gt;      @foreach ($data as $message)         &lt;p&gt;{{ $message-&gt;code }} : {{ $message-&gt;message }}&lt;\/p&gt;     @endforeach  &lt;\/body&gt;&lt;\/html&gt; <\/code><\/pre>\n<p>  \u0422\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 Ubuntu 20.04 \/ PHP 7.4 \/ Comet 0.6 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u043a\u0435 \u0441 4 \u044f\u0434\u0440\u0430\u043c\u0438 Ryzen 3600 \u0438 4G \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<pre><code class=\"php\">wrk --connections=500 --threads=2 --duration=10s http:\/\/comet:8080\/php <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0441\u043a\u043b\u0430\u0434, \u043a\u0430\u0436\u0434\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vj\/6b\/9v\/vj6b9vxjppclb717kyortk_9v20.jpeg\"><\/p>\n<p>  \u0427\u0438\u0441\u0442\u044b\u0439 PHP \u2014 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u043f\u0435\u0440\u0432\u044b\u0439, \u043d\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e, \u0447\u0442\u043e Blade \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u0430\u0436 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430! \u0418 \u043f\u043e\u0447\u0435\u043c\u0443 \u00ab\u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439\u00bb Plates \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u043e\u0442 \u00ab\u043c\u043e\u0449\u043d\u043e\u0433\u043e\u00bb Twig? \u0412\u0441\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0448\u0442\u0430\u0442\u043d\u043e\u0435 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u044b \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>  \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u043a\u043e\u0434\u0430, \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0432\u0438\u0436\u043a\u043e\u0432, \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c \u0432\u0430\u0436\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u0432\u044b\u0431\u043e\u0440\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0442\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u2014 \u043d\u0430\u043f\u0438\u0448\u0443 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u041d\u0430 \u043f\u0440\u0430\u0432\u0430\u0445 \u0440\u0435\u043a\u043b\u0430\u043c\u044b: \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 <a href=\"https:\/\/github.com\/gotzmann\/comet\" rel=\"nofollow\">Comet<\/a>, \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u043f\u043b\u0430\u043d\u0430\u0445 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c PHP-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f resful API \u0438 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \ud83d\ude42<\/div>\n<p> \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\/504720\/\"> https:\/\/habr.com\/ru\/post\/504720\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504720\/\">\u0412\u044b\u0431\u0438\u0440\u0430\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/github.com\/gotzmann\/comet\" rel=\"nofollow\">Comet<\/a>, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432 PHP-\u043a\u043e\u043c\u043c\u044c\u044e\u043d\u0438\u0442\u0438 \u0434\u0432\u0438\u0436\u043a\u0438. \u041e\u0431\u044b\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u0438\u043a\u0442\u0443\u0435\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a: \u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0441\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u0442 \u0432 Twig, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 Laravel \u0432\u043e\u043e\u0440\u0443\u0436\u0438\u0442\u0441\u044f Blade. \u041d\u043e \u043c\u0435\u043d\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u043a\u0430\u043a \u044d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438? \u041f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u043c\u0438 \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u0438 \u0447\u0438\u0441\u0442\u043e\u0433\u043e PHP \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043e\u0442\u0432\u0435\u0442. \u0414\u0430\u043d\u043d\u044b\u0435, \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u044b \u0438 \u043b\u0443\u0437\u0435\u0440\u044b \u2014 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a6\/l3\/n5\/a6l3n5qvorltm0fyii7l_xjtrsw.jpeg\">  <\/p>\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-304613","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304613","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=304613"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304613\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}