{"id":325714,"date":"2021-06-30T09:00:23","date_gmt":"2021-06-30T09:00:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=325714"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=325714","title":{"rendered":"\u041d\u0430 php \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/100\/7af\/d0f\/1007afd0f2204961850285672c277ea8.png\" width=\"1921\" height=\"1301\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044f\u0437\u044b\u043a php \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0431\u0435\u043a\u044d\u043d\u0434\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0430 \u0432 \u0434\u0435\u0432\u044f\u043d\u043e\u0441\u0442\u044b\u0435 \u0438 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b \u0442\u0430\u043a\u0443\u044e \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c (\u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u0443\u044e \u0441 IE \u0434\u043b\u044f \u0432\u0435\u0431-\u0441\u0435\u0440\u0444\u0438\u0433\u0430 \u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438) \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u0438, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043a\u043e\u0434\u0430. \u041d\u043e \u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 php \u0441\u0442\u0430\u043b\u0438 \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u044b, \u0434\u043e\u043b\u0433\u043e \u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \/vendor&#8230;<\/p>\n<p>\u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0432\u0441\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043d\u043e \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0430\u0447\u0435. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u0438\u043b\u0438\u0439 \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Node.js \u0438\u043b\u0438 Go.<\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043c\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0439 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c API \u043d\u0430 php.<\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043c\u043d\u0435 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Slim (<a href=\"https:\/\/www.slimframework.com\/\"><u>https:\/\/www.slimframework.com\/<\/u><\/a><u>), <\/u>\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043c\u0435\u044e \u043e\u043f\u044b\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f\/\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441 \u043d\u0443\u043b\u044f \u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u0430, \u0438 ORM, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u044b\u0445 CMS, \u0438 \u044d\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u043f\u0440\u043e &#171;\u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043b\u0435\u0433\u043a\u043e&#187;.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 Slim \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043d\u0430 php. \u041a\u0440\u043e\u043c\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (Apache 2, Nginx \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043d\u0430 \u043d\u0430\u0448 \u0432\u043a\u0443\u0441), \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 composer, \u043d\u043e \u044d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u044b\u0447\u043d\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445, \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043a\u0443\u0445\u0430\u0440\u0438\u0442\u044c (cooking app):<\/p>\n<pre><code class=\"bash\">mkdir my-slim-api &amp;&amp; cd my-slim-api composer init<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0444\u0430\u0439\u043b composer.json \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"json\">{    \"name\": \"zhukmax\/slim\",    \"type\": \"project\",    \"license\": \"MIT\",    \"autoload\": {      \"psr-4\": {        \"Zhukmax\\\\Slim\\\\\": \"src\/\"      }    },    \"require\": {} }<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u0430\u043c Slim, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 http-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (PSR-7) \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0444\u0430\u0431\u0440\u0438\u043a http-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (PSR-17):<\/p>\n<pre><code class=\"bash\">composer require slim\/slim:\"4.*\" composer require slim\/psr7<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API \u0432 \u043e\u0434\u043d\u043e\u043c index-\u0444\u0430\u0439\u043b\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0435, \u043a\u0430\u043a \u0441\u0435\u0439\u0447\u0430\u0441 &#171;\u043c\u043e\u0434\u043d\u043e-\u043c\u043e\u043b\u043e\u0434\u0435\u0436\u043d\u043e&#187;, json \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0442\u0435\u043b\u0435 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php  require __DIR__ . '\/vendor\/autoload.php';    use Psr\\Http\\Message\\ResponseInterface as Response;  use Psr\\Http\\Message\\ServerRequestInterface as Request;  use Slim\\Factory\\AppFactory;    $app = AppFactory::create();    $app-&gt;get('\/', function (Request $request, Response $response, $args) {   $data = array('name' =&gt; 'Max', 'role' =&gt; 'web developer');   $response-&gt;getBody()-&gt;write(json_encode($data));    return $response-&gt;withHeader('Content-Type', 'application\/json');  });    $app-&gt;run();<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u0432 composer.json \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 php-json (\u0438 \u0435\u0441\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u2013 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c)<\/p>\n<pre><code class=\"json\">\"require\": {   \"slim\/slim\": \"4.*\",   \"slim\/psr7\": \"^1.4\",   \"ext-json\": \"*\" }<\/code><\/pre>\n<h2>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 MySQL<\/h2>\n<p>\u0412 Slim \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0430\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437 ORM. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442 Laravel Eloquent \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0443\u044e Doctrine, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 NoSQL \u0431\u0430\u0437\u0430\u043c\u0438. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b\u0431\u0435\u0440\u0435\u043c Idiorm \u0437\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"bash\">composer require j4mie\/idiorm<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"php\">&lt;?php  ORM::configure([   \/\/ \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e localhost \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e,   \/\/ \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0430\u043d\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 127.0.0.1    'connection_string' =&gt; 'mysql:host=127.0.0.1;dbname=mydb',    'username' =&gt; 'root',    'password' =&gt; '124'  ]);   $app-&gt;get('\/users', function (Request $request, Response $response, $args) {    $users = ORM::forTable(\"users\")-&gt;find_array();   $response-&gt;getBody()-&gt;write(json_encode($users));    return $response; }); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c url, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 users \u0432 \u0432\u0438\u0434\u0435 json-\u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0442\u044c, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c<\/h2>\n<p>\u0412\u0441\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c GET, POST, PUT \u0438 DELETE http-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<pre><code class=\"php\">&lt;?php  $app-&gt;post('\/users', function (Request $request, Response $response, $args) {    $parsedBody = $request-&gt;getParsedBody();      $user = ORM::forTable(\"users\")-&gt;create();    $user-&gt;name = $parsedBody['name'] ?? '';      if ($user-&gt;save()) {      $successRes = $response-&gt;withStatus(201);      $successRes-&gt;getBody()-&gt;write(json_encode([        \"message\" =&gt; \"Success\"      ]));    \t  return $successRes;    } else {      $errorRes = $response-&gt;withStatus(501);      $errorRes-&gt;getBody()-&gt;write(json_encode([        \"message\" =&gt; \"Error\"      ]));          return $errorRes;    }  });<\/code><\/pre>\n<p>\u041c\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043a\u043e\u0434 \u0431\u044b\u043b \u0433\u043e\u0442\u043e\u0432 \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432 \u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0445 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e ORM. \u0412 Idiorm \u043d\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0434\u0430 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0437\u0430 \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438. \u041c\u044b \u0436\u0435 \u0445\u043e\u0442\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0435\u0435 API, \u0430 \u0434\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u043e \u0443\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u0433\u043e\u0434\u0430\u043c\u0438, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430.<\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 actions<\/h2>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c index.php \u0444\u0430\u0439\u043b\u0435 \u2013 \u0437\u0430\u0442\u0435\u044f \u043d\u0435 \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432. \u0412 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0443\u0442\u0438 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435-\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435.<\/p>\n<pre><code class=\"php\">$app-&gt;get('\/users\/{id}', [UserController::class, \"getOne\"]);<\/code><\/pre>\n<p>\u0427\u0442\u043e \u043c\u043d\u0435 \u043b\u0438\u0447\u043d\u043e \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0443 Slim \u2013 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043d\u0435\u0433\u043b\u0430\u0441\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043b\u043e\u0432\u0430 action \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0430 \u043c\u043e\u0436\u0435\u043c \u043e\u0442 \u043d\u0435\u0433\u043e \u043e\u0442\u043e\u0439\u0442\u0438 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430. \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0435 \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u043e\u0431\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043a\u043e\u0434 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u0430\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435. \u041b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0445\u0435\u043b\u043f\u0435\u0440\u044b \u0438 \u0442\u0440\u0435\u0439\u0442\u044b. \u041d\u0435 \u0442\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u044d\u0442\u043e \u0432\u0441\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435, \u043d\u043e \u043a\u0430\u043a \u0436\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u0438\u043b\u043e \u0441\u0435\u0440\u0434\u0446\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"php\">&lt;?php  class UserController  {    public function getOne(Request $request, Response $response, $args): Response    {      $id = (int)$args['id'] ?? 0;      $user = ORM::forTable(\"table1\")-&gt;findOne($id);        if (!$user) {        return self::errorResponse($response, 404, \"Error text\");      }        $response-&gt;getBody()-&gt;write(json_encode([        \"id\" =&gt; $user-&gt;id,        \"name\" =&gt; $user-&gt;name      ]));        return $response;    }     private static function errorResponse(Response $response, int $code, string $text): Response    {      $errorRes = $response-&gt;withStatus($code);      $errorRes-&gt;getBody()-&gt;write(json_encode([        \"message\" =&gt; $text      ]));        return $errorRes;    } }<\/code><\/pre>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441. \u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0431\u0440\u043e\u0441\u0430\u0442\u044c \u043d\u0430 php \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API, \u043a\u0430\u043a \u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u0434\u0435\u043b\u0430\u043b \u043d\u0430 Express, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Angular \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043d\u0430 backend. \u0418 \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u043e\u0438\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u043d \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u043c \u0438 \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u0432 \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u043f\u044b\u0442\u043d\u044b\u043c web-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0432 \u0441\u0442\u0430\u0442\u044c\u044e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0438 \u043e\u043d\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0441\u044f, \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043d\u0430 github \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 (<a href=\"https:\/\/github.com\/ZhukMax\/slim-api\"><u>https:\/\/github.com\/ZhukMax\/slim-api<\/u><\/a>), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043a\u043e\u0434.<\/p>\n<\/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\/company\/reksoft\/blog\/565372\/\"> https:\/\/habr.com\/ru\/company\/reksoft\/blog\/565372\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044f\u0437\u044b\u043a php \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0431\u0435\u043a\u044d\u043d\u0434\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0430 \u0432 \u0434\u0435\u0432\u044f\u043d\u043e\u0441\u0442\u044b\u0435 \u0438 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b \u0442\u0430\u043a\u0443\u044e \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c (\u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u0443\u044e \u0441 IE \u0434\u043b\u044f \u0432\u0435\u0431-\u0441\u0435\u0440\u0444\u0438\u0433\u0430 \u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438) \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u0438, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043a\u043e\u0434\u0430. \u041d\u043e \u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 php \u0441\u0442\u0430\u043b\u0438 \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u044b, \u0434\u043e\u043b\u0433\u043e \u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \/vendor&#8230;<\/p>\n<p>\u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0432\u0441\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043d\u043e \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0430\u0447\u0435. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u0438\u043b\u0438\u0439 \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Node.js \u0438\u043b\u0438 Go.<\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043c\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0439 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c API \u043d\u0430 php.<\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043c\u043d\u0435 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Slim (<a href=\"https:\/\/www.slimframework.com\/\"><u>https:\/\/www.slimframework.com\/<\/u><\/a><u>), <\/u>\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043c\u0435\u044e \u043e\u043f\u044b\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f\/\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441 \u043d\u0443\u043b\u044f \u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u0430, \u0438 ORM, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u044b\u0445 CMS, \u0438 \u044d\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u043f\u0440\u043e &#171;\u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043b\u0435\u0433\u043a\u043e&#187;.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 Slim \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043d\u0430 php. \u041a\u0440\u043e\u043c\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (Apache 2, Nginx \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043d\u0430 \u043d\u0430\u0448 \u0432\u043a\u0443\u0441), \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 composer, \u043d\u043e \u044d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u044b\u0447\u043d\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445, \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043a\u0443\u0445\u0430\u0440\u0438\u0442\u044c (cooking app):<\/p>\n<pre><code class=\"bash\">mkdir my-slim-api &amp;&amp; cd my-slim-api composer init<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0444\u0430\u0439\u043b composer.json \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"json\">{    \"name\": \"zhukmax\/slim\",    \"type\": \"project\",    \"license\": \"MIT\",    \"autoload\": {      \"psr-4\": {        \"Zhukmax\\\\Slim\\\\\": \"src\/\"      }    },    \"require\": {} }<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u0430\u043c Slim, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 http-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (PSR-7) \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0444\u0430\u0431\u0440\u0438\u043a http-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (PSR-17):<\/p>\n<pre><code class=\"bash\">composer require slim\/slim:\"4.*\" composer require slim\/psr7<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API \u0432 \u043e\u0434\u043d\u043e\u043c index-\u0444\u0430\u0439\u043b\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0435, \u043a\u0430\u043a \u0441\u0435\u0439\u0447\u0430\u0441 &#171;\u043c\u043e\u0434\u043d\u043e-\u043c\u043e\u043b\u043e\u0434\u0435\u0436\u043d\u043e&#187;, json \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0442\u0435\u043b\u0435 \u043e\u0442\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php  require __DIR__ . '\/vendor\/autoload.php';    use Psr\\Http\\Message\\ResponseInterface as Response;  use Psr\\Http\\Message\\ServerRequestInterface as Request;  use Slim\\Factory\\AppFactory;    $app = AppFactory::create();    $app-&gt;get('\/', function (Request $request, Response $response, $args) {   $data = array('name' =&gt; 'Max', 'role' =&gt; 'web developer');   $response-&gt;getBody()-&gt;write(json_encode($data));    return $response-&gt;withHeader('Content-Type', 'application\/json');  });    $app-&gt;run();<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u0432 composer.json \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 php-json (\u0438 \u0435\u0441\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u2013 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c)<\/p>\n<pre><code class=\"json\">\"require\": {   \"slim\/slim\": \"4.*\",   \"slim\/psr7\": \"^1.4\",   \"ext-json\": \"*\" }<\/code><\/pre>\n<h2>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 MySQL<\/h2>\n<p>\u0412 Slim \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0430\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437 ORM. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442 Laravel Eloquent \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0443\u044e Doctrine, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 NoSQL \u0431\u0430\u0437\u0430\u043c\u0438. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b\u0431\u0435\u0440\u0435\u043c Idiorm \u0437\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"bash\">composer require j4mie\/idiorm<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"php\">&lt;?php  ORM::configure([   \/\/ \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e localhost \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e,   \/\/ \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0430\u043d\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 127.0.0.1    'connection_string' =&gt; 'mysql:host=127.0.0.1;dbname=mydb',    'username' =&gt; 'root',    'password' =&gt; '124'  ]);   $app-&gt;get('\/users', function (Request $request, Response $response, $args) {    $users = ORM::forTable(\"users\")-&gt;find_array();   $response-&gt;getBody()-&gt;write(json_encode($users));    return $response; }); <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c url, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 users \u0432 \u0432\u0438\u0434\u0435 json-\u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0442\u044c, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c<\/h2>\n<p>\u0412\u0441\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c GET, POST, PUT \u0438 DELETE http-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<pre><code class=\"php\">&lt;?php  $app-&gt;post('\/users', function (Request $request, Response $response, $args) {    $parsedBody = $request-&gt;getParsedBody();      $user = ORM::forTable(\"users\")-&gt;create();    $user-&gt;name = $parsedBody['name'] ?? '';      if ($user-&gt;save()) {      $successRes = $response-&gt;withStatus(201);      $successRes-&gt;getBody()-&gt;write(json_encode([        \"message\" =&gt; \"Success\"      ]));    \t  return $successRes;    } else {      $errorRes = $response-&gt;withStatus(501);      $errorRes-&gt;getBody()-&gt;write(json_encode([        \"message\" =&gt; \"Error\"      ]));          return $errorRes;    }  });<\/code><\/pre>\n<p>\u041c\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043a\u043e\u0434 \u0431\u044b\u043b \u0433\u043e\u0442\u043e\u0432 \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432 \u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0445 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e ORM. \u0412 Idiorm \u043d\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0434\u0430 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0437\u0430 \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438. \u041c\u044b \u0436\u0435 \u0445\u043e\u0442\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0435\u0435 API, \u0430 \u0434\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u043e \u0443\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u0433\u043e\u0434\u0430\u043c\u0438, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430.<\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 actions<\/h2>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c index.php \u0444\u0430\u0439\u043b\u0435 \u2013 \u0437\u0430\u0442\u0435\u044f \u043d\u0435 \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432. \u0412 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0443\u0442\u0438 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435-\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435.<\/p>\n<pre><code class=\"php\">$app-&gt;get('\/users\/{id}', [UserController::class, \"getOne\"]);<\/code><\/pre>\n<p>\u0427\u0442\u043e \u043c\u043d\u0435 \u043b\u0438\u0447\u043d\u043e \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0443 Slim \u2013 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043d\u0435\u0433\u043b\u0430\u0441\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043b\u043e\u0432\u0430 action \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0430 \u043c\u043e\u0436\u0435\u043c \u043e\u0442 \u043d\u0435\u0433\u043e \u043e\u0442\u043e\u0439\u0442\u0438 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430. \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0435 \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u043e\u0431\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043a\u043e\u0434 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u0430\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435. \u041b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0445\u0435\u043b\u043f\u0435\u0440\u044b \u0438 \u0442\u0440\u0435\u0439\u0442\u044b. \u041d\u0435 \u0442\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u044d\u0442\u043e \u0432\u0441\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435, \u043d\u043e \u043a\u0430\u043a \u0436\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u0438\u043b\u043e \u0441\u0435\u0440\u0434\u0446\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"php\">&lt;?php  class UserController  {    public function getOne(Request $request, Response $response, $args): Response    {      $id = (int)$args['id'] ?? 0;      $user = ORM::forTable(\"table1\")-&gt;findOne($id);        if (!$user) {        return self::errorResponse($response, 404, \"Error text\");      }        $response-&gt;getBody()-&gt;write(json_encode([        \"id\" =&gt; $user-&gt;id,        \"name\" =&gt; $user-&gt;name      ]));        return $response;    }     private static function errorResponse(Response $response, int $code, string $text): Response    {      $errorRes = $response-&gt;withStatus($code);      $errorRes-&gt;getBody()-&gt;write(json_encode([        \"message\" =&gt; $text      ]));        return $errorRes;    } }<\/code><\/pre>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441. \u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0431\u0440\u043e\u0441\u0430\u0442\u044c \u043d\u0430 php \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API, \u043a\u0430\u043a \u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u0434\u0435\u043b\u0430\u043b \u043d\u0430 Express, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Angular \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043d\u0430 backend. \u0418 \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u043e\u0438\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u043d \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u043c \u0438 \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u0432 \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u043f\u044b\u0442\u043d\u044b\u043c web-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0432 \u0441\u0442\u0430\u0442\u044c\u044e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0438 \u043e\u043d\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0441\u044f, \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043d\u0430 github \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 (<a href=\"https:\/\/github.com\/ZhukMax\/slim-api\"><u>https:\/\/github.com\/ZhukMax\/slim-api<\/u><\/a>), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043a\u043e\u0434.<\/p>\n<\/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\/company\/reksoft\/blog\/565372\/\"> https:\/\/habr.com\/ru\/company\/reksoft\/blog\/565372\/<\/a><br \/><\/br><\/br><\/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-325714","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325714","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=325714"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325714\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}