{"id":256417,"date":"2015-04-30T15:55:02","date_gmt":"2015-04-30T11:55:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=256417"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=256417","title":{"rendered":"\u041c\u0438\u043d\u0438 API \u043d\u0430 Lumen"},"content":{"rendered":"<p> \t\t\t<img decoding=\"async\" src=\"http:\/\/i.imgur.com\/y7U96h6.png\" alt=\"image\"\/><\/p>\n<p>  \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e API \u043d\u0430 Lumen \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u043e\u0442 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0442\u0430. \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d <a href=\"https:\/\/github.com\/buzdykg\/Lumen\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b \u044f \u0435\u0433\u043e \u043d\u0430 \u0431\u043e\u043a\u0441 homestead, \u0442.\u0447. \u0443\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439:<\/p>\n<pre><code class=\"bash\">composer create-project laravel\/lumen --prefer-dist Lumen <\/code><\/pre>\n<p>  <a href=\"http:\/\/laravel.com\/docs\/5.0\/homestead\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/a> \u043e homestead.<\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 Laravel:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/i.imgur.com\/U2jXH7i.png\" alt=\"image\"\/><\/p>\n<p>  \u0411\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 \/config. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e Lumen \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 .env \u0444\u0430\u0439\u043b\u0430. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e:<\/p>\n<pre><code class=\"bash\">DB_CONNECTION=mysql DB_USERNAME=homestead DB_PASSWORD=secret DB_DATABASE=lumen <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432 vendor\/laravel\/lumen-framework\/config\/.<\/p>\n<p>  \u0418\u0442\u0430\u043a,<\/p>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0411\u0414<\/h2>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u0442, \u043f\u043b\u044e\u0441 2 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u043b\u043e\u0433\u0438\u043d.<br \/>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 artisan.<\/p>\n<pre><code class=\"bash\">php artisan make:migration create_users_table php artisan make:migration create_posts_table <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 \/database \u043b\u0435\u0436\u0438\u0442 2 \u043d\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u0430. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e 2 \u043c\u0435\u0442\u043e\u0434\u0430, up \u0438 down \u2014 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0438 \u043e\u0442\u043c\u0435\u043d\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438.<br \/>  \u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 up \u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b users:<\/p>\n<pre><code class=\"php\">\/\/database\/*create_users_table.php Schema::create('users', function (Blueprint $table) {     $table-&gt;increments('id');     $table-&gt;string('email')-&gt;unique();     $table-&gt;string('first_name');     $table-&gt;string('last_name');     $table-&gt;string('password');     $table-&gt;rememberToken();     $table-&gt;timestamps();     $table-&gt;softDeletes(); }); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"php\">\/\/database\/*create_posts_table.php Schema::create('posts', function (Blueprint $table) {     $table-&gt;increments('id');     $table-&gt;string('user_id');     $table-&gt;string('content');     $table-&gt;timestamps();     $table-&gt;softDeletes(); }); <\/code><\/pre>\n<p>  \u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0433\u043e\u0442\u043e\u0432\u044b, \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c:<\/p>\n<pre><code class=\"bash\">php artisan migrate <\/code><\/pre>\n<p>  \u041d\u043e \u0430\u0440\u0442\u0438\u0441\u0430\u043d \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 .env \u0444\u0430\u0439\u043b\u0430 \u0438 \u0436\u0430\u043b\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043b\u043e\u0445\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043d\u0443\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 \/bootstrap\/app.php:<\/p>\n<pre><code class=\"php\">Dotenv::load(__DIR__.'\/..\/'); <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d ORM Eloquent \u0438 \u0444\u0430\u0441\u0430\u0434\u044b. \u0428\u0442\u0443\u043a\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438\u0445 \u0442\u043e\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043b.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/i.imgur.com\/yLrEGhz.png\" alt=\"image\"\/><br \/>  (art \u2014 \u044d\u0442\u043e alias \u0434\u043b\u044f php artisan)<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c Eloquent \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0441\u0442\u0430:<\/p>\n<pre><code class=\"php\">use Illuminate\\Database\\Eloquent\\Model;  class Post extends Model {     \/**      * @return \\Illuminate\\Database\\Eloquent\\Relations\\BelongsTo      *\/     public function user()     {         return $this-&gt;belongsTo('Written\\Models\\User');     } } <\/code><\/pre>\n<p>  \u041c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0431\u043e\u043b\u044c\u044e \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0442.\u043a. \u043e\u043d\u0438 \u0437\u0430\u0431\u043e\u0442\u044f\u0442\u0441\u044f \u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u0442\u0430\u0431\u043b\u0438\u0446. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u00ab\u0441\u044b\u0440\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0434 \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0443\u043a\u043b\u043e\u043d\u043d\u043e \u0434\u0435\u0433\u0440\u0430\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0422\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0443\u043c\u0435\u0441\u0442\u043d\u044b, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a.<\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b<\/h2>\n<p>  \u0412 Laravel 5 \u0435\u0441\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 Trait, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0432 \u0434\u0432\u0430 \u0449\u0435\u043b\u0447\u043a\u0430 \u043f\u0430\u043b\u044c\u0446\u0435\u0432. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0432 Lumen \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435\u0442. \u0422\u0430\u043a\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0440\u043e\u0443\u0442\u044b \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">\/**  * @Middleware(&quot;auth.token&quot;)  * @Resource('post')  *\/ class PostsController extends Controller {     public function index() {}     public function show($id) {}     public function store() {}     public function update() {}     public function destroy() {} } <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 RESTful. \u0422.\u043e. \u0438\u043c\u0435\u044f \u043f\u0435\u0440\u0435\u0434 \u0433\u043b\u0430\u0437\u0430\u043c\u0438 1 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0444\u0430\u0439\u043b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c, \u0438 \u0447\u0442\u043e \u0437\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u0431\u044b <a href=\"http:\/\/laravelcollective.com\/docs\/5.0\/annotations\">laravelcollective\/annotations<\/a>. \u041d\u043e \u0441 Lumen \u043e\u043d\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0440\u043e\u0443\u0442\u044b \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0445\u0430\u0442\u044c \u0432 \/app\/http\/routes.php:<\/p>\n<pre><code class=\"php\">$app-&gt;get('\/', function() use ($app) {     return $app-&gt;welcome(); }); $app-&gt;post('\/register', ['uses' =&gt; 'App\\Http\\Controllers\\AuthController@postRegister']); $app-&gt;post('\/login', ['uses'    =&gt; 'App\\Http\\Controllers\\AuthController@postLogin']);  $app-&gt;get('\/post\/{id}', ['uses' =&gt; 'App\\Http\\Controllers\\PostsController@show']); $app-&gt;get('\/post',      ['uses' =&gt; 'App\\Http\\Controllers\\PostsController@index']); $app-&gt;group(['middleware' =&gt; 'logged.in'], function($app) {     $app-&gt;post('\/post',     ['uses' =&gt; 'App\\Http\\Controllers\\PostsController@store']);     \/** & another protected routes *\/ }); <\/code><\/pre>\n<p>  \u0412 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<p>  \u0423 Lumen, \u043a\u0430\u043a \u0438 \u0443 Laravel, \u0435\u0441\u0442\u044c Middleware, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043b\u0438\u0431\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043b\u0438\u0431\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u044f\u043a\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412\u0441\u0435 \u0442\u0430\u043a\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043b\u0435\u0436\u0430\u0442 \u0432 \/app\/Http\/Middleware\/. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b Lumen \u0437\u043d\u0430\u043b \u043e\u0431 \u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \/bootstrap.app.php.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 Middleware:<\/p>\n<pre><code class=\"php\">\/\/app\/Http\/Middlewared\/LoggedInMiddleware.php class LoggedInMiddleware {     \/**      * Handle an incoming request.      *      * @param  \\Illuminate\\Http\\Request  $request      * @param  \\Closure  $next      * @return mixed      *\/     public function handle($request, Closure $next)     {         if(!Auth::check()) {             return new Response('', 401);         }          return $next($request);     } } <\/code><\/pre>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u0432\u044b\u0434\u0430\u0451\u0442 http \u043a\u043e\u0434 401, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442 \u043d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<pre><code class=\"php\">\/\/app\/Http\/Controller\/PostsController.php \/**  * Class PostsController  * @package App\\Http\\Controllers  *\/ class PostsController extends Controller {     public function index()     {         return $this-&gt;respondWithData(Post::with('user')-&gt;all()-&gt;toArray());     }      public function show($id)     {         return $this-&gt;respondWithData(Post::find($id)-&gt;with('user')-&gt;get()-&gt;toArray());     }      public function store()     {         $rules = [             'text' =&gt; 'required',         ];          $input = $_POST;          $validator = Validator::make($input, $rules);         if ($validator-&gt;fails()) {             return $this-&gt;respondWithFailedValidation($validator);         }          $post = new Post;         $post-&gt;content = $input['content'];         $post-&gt;user()-&gt;associate(Auth::user());         $post-&gt;save();          return $this-&gt;show($post-&gt;id);     }  \/\/    public function delete() {} } <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0444\u0438\u0442\u0430 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Eloquent \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 show(). \u041a\u043b\u0438\u0435\u043d\u0442\u0443 \u043e\u0442\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u0441\u0442\u0435, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043e\u0431 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435.<\/p>\n<p>  respondWith* \u043c\u0435\u0442\u043e\u0434\u044b \u2014 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435, \u0434\u043b\u044f \u043f\u0440\u0438\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0443 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438. \u0412 \u0446\u0435\u043b\u043e\u043c \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041d\u0435 \u0437\u0440\u044f \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043e, \u0447\u0442\u043e Lumen \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441 Laravel, \u0442.\u043a. \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u044f \u043d\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u044e, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e Lumen.<\/p>\n<p>  \u041d\u043e \u0432\u0441\u0451 \u0436\u0435 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0430\u0436\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043e\u0441\u0430\u0434\u043e\u0447\u0435\u043a:<br \/>   \u2014 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f Laravel. \u0422\u0435 \u0436\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0434\u0435-\u0444\u0430\u043a\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442;<br \/>   \u2014 \u0434\u043b\u044f \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c Laravel, \u0442.\u043a. \u043c\u043d\u043e\u0433\u043e\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u0434\u043e\u043a\u0430\u0445 Laravel \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0430 \u0432 \u0434\u043e\u043a\u0430\u0445 Lumen \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u0430\u043b\u043e. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u0430\u0441\u0430\u0434\u044b \u2014 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435. \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u0440\u0443\u0447\u043a\u0430\u043c\u0438;<br \/>   \u2014 \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u044b \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u0442.\u043a. \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u0435\u0442 $_POST.<\/p>\n<p>  \u0423 \u043c\u0435\u043d\u044f \u0442\u043e\u043b\u044c\u043a\u043e <s>\u043e\u0434\u0438\u043d<\/s>\u0434\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u2014 \u0437\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d Lumen, \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c Laravel? \u0420\u0430\u0437\u0432\u0435 \u0435\u0441\u0442\u044c \u043b\u044e\u0434\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u044f\u0442 \u043c\u0435\u0433\u0430\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u0438\u0448\u0443\u0442 \u0441\u0432\u043e\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435? \t\t\t<\/p>\n<div class=\"clear\"><\/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=\"http:\/\/habrahabr.ru\/post\/257073\/\"> http:\/\/habrahabr.ru\/post\/257073\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t<img decoding=\"async\" src=\"http:\/\/i.imgur.com\/y7U96h6.png\" alt=\"image\"\/><\/p>\n<p>  \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e API \u043d\u0430 Lumen \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u043e\u0442 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0442\u0430. \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d <a href=\"https:\/\/github.com\/buzdykg\/Lumen\">\u0437\u0434\u0435\u0441\u044c<\/a>.  <\/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-256417","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256417","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=256417"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256417\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}