{"id":324810,"date":"2021-06-11T21:00:25","date_gmt":"2021-06-11T21:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=324810"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=324810","title":{"rendered":"\u0420\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Symfony \u0432 AWS Lambda"},"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\/f17\/2d5\/60b\/f172d560bf38ff4ca5809c5f9c7ceaef.png\" width=\"780\" height=\"439\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0438 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<p>\u0411\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0431\u0435\u0437 \u043c\u043e\u0440\u043e\u043a\u0438 \u0441 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439: \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u0430\u043c \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u043a\u043e\u0434\u0435.<\/p>\n<p>AWS Lambda \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u0438\u0447\u0435\u043c \u043f\u043b\u0430\u0442\u0430 \u0432\u0437\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u042d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a cron-\u0437\u0430\u0434\u0430\u043d\u0438\u0439, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a API, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u0430\u043a\u0438\u0445-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0442.&nbsp;\u0434. \u0412 \u0441\u0435\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u0441\u0441\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<h3>\u041d\u0430\u0448 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f&nbsp;<\/h3>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a API, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/symfony.com\/\"><u>Symfony<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 <a href=\"https:\/\/www.linkedin.com\/\"><u>LinkedIn<\/u><\/a>. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u0442\u0430\u043f\u044b \u043e\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/p>\n<h3>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434&nbsp;<\/h3>\n<p>\u0412 Symfony 5-\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/symfony.com\/doc\/current\/notifier.html\"><u>Notifier<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b (<a href=\"https:\/\/slack.com\/\"><u>Slack<\/u><\/a>, <a href=\"https:\/\/twitter.com\/Eniams_Dev\"><u>Twitter<\/u><\/a>, <a href=\"https:\/\/www.twilio.com\/sms\"><u>Twilio<\/u><\/a> \u0438 \u0434\u0440.).<\/p>\n<p>\u0412 Symfony \u043d\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 <a href=\"https:\/\/www.linkedin.com\/in\/smainemilianni\/\"><u>LinkedIn<\/u><\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u043e\u0432\u0435\u0440\u0445 Notifier \u0448\u043b\u044e\u0437 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0448\u043b\u044e\u0437\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/ismail1432\/notifier-linkedin\"><u>\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/u><\/a>, \u0435\u0433\u043e \u0436\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u044d\u0442\u043e\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/strong><\/p>\n<pre><code class=\"php\">$ symfony new --full aws-lambda-linkedin-notifier $ cd aws-lambda-linkedin-notifier $ composer require eniams\/linkedin-notifier<\/code><\/pre>\n<p>\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0448\u043b\u044e\u0437 (<a href=\"https:\/\/github.com\/ismail1432\/notifier-linkedin\"><u>\u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/u><\/a>)<\/p>\n<pre><code class=\"php\">&lt;?php \/\/ config\/bundles.php return [ \/\/ others bundles, Eniams\\Notifier\\LinkedIn\\LinkedInNotifierBundle::class =&gt; ['all' =&gt; true]]; \/\/ .env LINKEDIN_DSN=<\/code><\/pre>\n<p><strong>\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430<\/strong><\/p>\n<pre><code class=\"php\"> &lt;?php  class PostContentController {     \/**      * @Route(\"\/contents\", name=\"post_content\", methods=\"POST\")      *\/     public function __invoke(NotifierInterface $notifier, Request $request)     {         if(null !== $message = (\\json_decode($request-&gt;getContent(), true)['message'] ?? null)) {             $notifier-&gt;send(new Notification($message, ['chat\/linkedin']));             return new JsonResponse('message posted with success', 201);         }          throw new BadRequestException('Missing \"message\" in body');     } }<\/code><\/pre>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430: \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a API \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 <code>\/contents<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 POST \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c <code>message<\/code> \u0432 \u0435\u0433\u043e \u0442\u0435\u043b\u0435.<\/p>\n<p>\u0412 11-\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 LinkedIn&nbsp;\u2014 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f Symfony \u0438 \u0448\u043b\u044e\u0437\u0443 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e!<\/p>\n<p>\u0411\u0443\u0434\u0443\u0447\u0438 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438, \u043f\u043e\u043a\u0440\u043e\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\"> &lt;?php class PostContentControllerTest extends WebTestCase     \/**      * @dataProvider methodProvider      *\/     public function testANoPostRequestShouldReturnA405(string $method)     {         $client = static::createClient();          $client-&gt;request($method, '\/contents');          self::assertEquals(405, $client-&gt;getResponse()-&gt;getStatusCode());     }      public function testAPostRequestWithoutAMessageInBodyShouldReturnA400()     {         $client = static::createClient();          $client-&gt;request('POST', '\/contents');          self::assertEquals(400, $client-&gt;getResponse()-&gt;getStatusCode());     }      public function testAPostRequestWithAMessageInBodyShouldReturnA201()     {         $request = new Request([],[],[],[],[],[], json_encode(['message' =&gt; 'Hello World']));          $notifier = new class implements NotifierInterface {             public function send(Notification $notification, Recipient ...$recipients): void             {             }         };          $controller = new PostContentController();         $response = $controller-&gt;__invoke($notifier, $request);          self::assertEquals(201, $response-&gt;getStatusCode());     }      public function methodProvider()     {         return [             ['GET'],             ['PUT'],             ['DELETE'],         ];     } view rawTestPostContentController.php hosted with \u200b by GitHub<\/code><\/pre>\n<h3>\u041a\u043e\u0434 \u0433\u043e\u0442\u043e\u0432! \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c&nbsp;<\/h3>\n<p>\u0421\u0442\u043e\u043f! \u0427\u0442\u043e?! AWS Lambda \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 PHP!<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a: AWS Lambda \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u0432\u0441\u0435 \u044f\u0437\u044b\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 <a href=\"https:\/\/dashbird.io\/blog\/most-effictient-lambda-language\/\"><u>Go, Java, Python, Ruby, NodeJS \u0438 .NET<\/u><\/a>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044f\u0437\u044b\u043a \u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0434? \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043d\u0435\u0442!<\/p>\n<p>\u041d\u0438\u0447\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <a href=\"https:\/\/mnapoli.fr\/\"><u>\u041c\u0430\u0442\u044c\u0435 \u041d\u0430\u043f\u043f\u043e\u043b\u0438 (Matthieu Nappoli)<\/u><\/a>, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044e <a href=\"https:\/\/bref.sh\/\"><u>Bref.sh<\/u><\/a>, \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0449\u0435\u0439 \u0435\u043c\u0443 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/brefphp\/bref\"><u>\u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c<\/u><\/a>.&nbsp;<\/p>\n<p>Bref \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u0442\u044c PHP-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 <a href=\"https:\/\/aws.amazon.com\/\"><u>AWS<\/u><\/a> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 <a href=\"https:\/\/aws.amazon.com\/lambda\/\"><u>AWS Lambda<\/u><\/a>.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 kernel.php \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043b\u043e\u0433\u043e\u0432:<\/p>\n<pre><code class=\"php\">&lt;?php     \/\/ Kernel.php     public function getLogDir(): string     {         if (getenv('LAMBDA_TASK_ROOT') !== false) {             return '\/tmp\/log\/';         }          return parent::getLogDir();     }      public function getCacheDir()     {         if (getenv('LAMBDA_TASK_ROOT') !== false) {             return '\/tmp\/cache\/'.$this-&gt;environment;         }          return parent::getCacheDir();     }<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Serverless <a href=\"https:\/\/bref.sh\/docs\/installation.html\"><u>(\u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e)<\/u><\/a>:<\/p>\n<pre><code class=\"php\">$ npm install -g serverless $ serverless config credentials --provider aws --key  --secret $ composer require bref\/bref<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0432 \u0444\u0430\u0439\u043b\u0435 serverless.yaml:<\/p>\n<pre><code class=\"php\">service: notifier-linkedin-api  provider:     name: aws     region: eu-west-3     runtime: provided     environment: # env vars         APP_ENV: prod         LINKEDIN_DSN: YOUR_DSN   plugins:     - .\/vendor\/bref\/bref  functions:     website:         handler: public\/index.php # bootstrap          layers:             - ${bref:layer.php-73-fpm} # https:\/\/bref.sh\/docs\/runtimes\/index.html#usage          timeout: 28 # Timeout to stop the compute time         events:             - http: 'POST \/contents' # Only POST to \/contents are allowed  package:     exclude:         - 'tests\/**' view rawserverless.yaml hosted with \u200b by GitHub<\/code><\/pre>\n<p>\u0420\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u0435\u043c!<\/p>\n<pre><code>$ serverless deploy Serverless: Packaging service... Serverless: Excluding development dependencies... Serverless: Uploading CloudFormation file to S3... Serverless: Uploading artifacts... Serverless: Uploading service notifier-linkedin-api.zip file to S3 (10.05 MB)... Serverless: Validating template... Serverless: Updating Stack... Serverless: Checking Stack update progress... .................... Serverless: Stack update finished... Service Information service: notifier-linkedin-api stage: dev region: eu-west-3 stack: notifier-linkedin-api-dev resources: 15 api keys:   None endpoints:   POST - https:\/\/xxx.execute-api.eu-west-3.amazonaws.com\/dev\/contents functions:   website: notifier-linkedin-api-dev-website layers:   None Serverless: Removing old service artifacts from S3... Serverless: Run the \"serverless\" command to setup monitoring, troubleshooting and testing.<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442 \u0432 AWS Lambda, \u0430 API \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>https:\/\/xxx.execute-api.eu-west-3.amazonaws.com\/dev\/contents<\/code>.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ddb\/8b3\/016\/ddb8b3016772a39eb40b15fba50f939e.png\" width=\"1295\" height=\"258\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/16f\/56a\/920\/16f56a920fcd887646786e52a29519e8.png\" width=\"568\" height=\"172\"><figcaption><\/figcaption><\/figure>\n<hr>\n<blockquote>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/KqEN\/\"><strong>&#171;Symfony Framework&#187;<\/strong><\/a>. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u043a\u0443\u0440\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043d\u0430 <a href=\"https:\/\/otus.pw\/CAZa\/\">\u0434\u0435\u043d\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0432\u0435\u0440\u0435\u0439<\/a> \u043e\u043d\u043b\u0430\u0439\u043d, \u0433\u0434\u0435 \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/blockquote>\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\/otus\/blog\/562392\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/562392\/<\/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>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0438 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<p>\u0411\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0431\u0435\u0437 \u043c\u043e\u0440\u043e\u043a\u0438 \u0441 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439: \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u0430\u043c \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u043a\u043e\u0434\u0435.<\/p>\n<p>AWS Lambda \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u0438\u0447\u0435\u043c \u043f\u043b\u0430\u0442\u0430 \u0432\u0437\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u042d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a cron-\u0437\u0430\u0434\u0430\u043d\u0438\u0439, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a API, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u0430\u043a\u0438\u0445-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0442.&nbsp;\u0434. \u0412 \u0441\u0435\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u0441\u0441\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<h3>\u041d\u0430\u0448 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f&nbsp;<\/h3>\n<p>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a API, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/symfony.com\/\"><u>Symfony<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 <a href=\"https:\/\/www.linkedin.com\/\"><u>LinkedIn<\/u><\/a>. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u0442\u0430\u043f\u044b \u043e\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/p>\n<h3>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434&nbsp;<\/h3>\n<p>\u0412 Symfony 5-\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/symfony.com\/doc\/current\/notifier.html\"><u>Notifier<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b (<a href=\"https:\/\/slack.com\/\"><u>Slack<\/u><\/a>, <a href=\"https:\/\/twitter.com\/Eniams_Dev\"><u>Twitter<\/u><\/a>, <a href=\"https:\/\/www.twilio.com\/sms\"><u>Twilio<\/u><\/a> \u0438 \u0434\u0440.).<\/p>\n<p>\u0412 Symfony \u043d\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 <a href=\"https:\/\/www.linkedin.com\/in\/smainemilianni\/\"><u>LinkedIn<\/u><\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u043e\u0432\u0435\u0440\u0445 Notifier \u0448\u043b\u044e\u0437 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0448\u043b\u044e\u0437\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/ismail1432\/notifier-linkedin\"><u>\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/u><\/a>, \u0435\u0433\u043e \u0436\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u044d\u0442\u043e\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/strong><\/p>\n<pre><code class=\"php\">$ symfony new --full aws-lambda-linkedin-notifier $ cd aws-lambda-linkedin-notifier $ composer require eniams\/linkedin-notifier<\/code><\/pre>\n<p>\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0448\u043b\u044e\u0437 (<a href=\"https:\/\/github.com\/ismail1432\/notifier-linkedin\"><u>\u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/u><\/a>)<\/p>\n<pre><code class=\"php\">&lt;?php \/\/ config\/bundles.php return [ \/\/ others bundles, Eniams\\Notifier\\LinkedIn\\LinkedInNotifierBundle::class =&gt; ['all' =&gt; true]]; \/\/ .env LINKEDIN_DSN=<\/code><\/pre>\n<p><strong>\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430<\/strong><\/p>\n<pre><code class=\"php\"> &lt;?php  class PostContentController {     \/**      * @Route(\"\/contents\", name=\"post_content\", methods=\"POST\")      *\/     public function __invoke(NotifierInterface $notifier, Request $request)     {         if(null !== $message = (\\json_decode($request-&gt;getContent(), true)['message'] ?? null)) {             $notifier-&gt;send(new Notification($message, ['chat\/linkedin']));             return new JsonResponse('message posted with success', 201);         }          throw new BadRequestException('Missing \"message\" in body');     } }<\/code><\/pre>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430: \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a API \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 <code>\/contents<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 POST \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c <code>message<\/code> \u0432 \u0435\u0433\u043e \u0442\u0435\u043b\u0435.<\/p>\n<p>\u0412 11-\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 LinkedIn&nbsp;\u2014 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f Symfony \u0438 \u0448\u043b\u044e\u0437\u0443 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e!<\/p>\n<p>\u0411\u0443\u0434\u0443\u0447\u0438 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438, \u043f\u043e\u043a\u0440\u043e\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\"> &lt;?php class PostContentControllerTest extends WebTestCase     \/**      * @dataProvider methodProvider      *\/     public function testANoPostRequestShouldReturnA405(string $method)     {         $client = static::createClient();          $client-&gt;request($method, '\/contents');          self::assertEquals(405, $client-&gt;getResponse()-&gt;getStatusCode());     }      public function testAPostRequestWithoutAMessageInBodyShouldReturnA400()     {         $client = static::createClient();          $client-&gt;request('POST', '\/contents');          self::assertEquals(400, $client-&gt;getResponse()-&gt;getStatusCode());     }      public function testAPostRequestWithAMessageInBodyShouldReturnA201()     {         $request = new Request([],[],[],[],[],[], json_encode(['message' =&gt; 'Hello World']));          $notifier = new class implements NotifierInterface {             public function send(Notification $notification, Recipient ...$recipients): void             {             }         };          $controller = new PostContentController();         $response = $controller-&gt;__invoke($notifier, $request);          self::assertEquals(201, $response-&gt;getStatusCode());     }      public function methodProvider()     {         return [             ['GET'],             ['PUT'],             ['DELETE'],         ];     } view rawTestPostContentController.php hosted with \u200b by GitHub<\/code><\/pre>\n<h3>\u041a\u043e\u0434 \u0433\u043e\u0442\u043e\u0432! \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c&nbsp;<\/h3>\n<p>\u0421\u0442\u043e\u043f! \u0427\u0442\u043e?! AWS Lambda \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 PHP!<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a: AWS Lambda \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u0432\u0441\u0435 \u044f\u0437\u044b\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 <a href=\"https:\/\/dashbird.io\/blog\/most-effictient-lambda-language\/\"><u>Go, Java, Python, Ruby, NodeJS \u0438 .NET<\/u><\/a>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044f\u0437\u044b\u043a \u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0434? \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043d\u0435\u0442!<\/p>\n<p>\u041d\u0438\u0447\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <a href=\"https:\/\/mnapoli.fr\/\"><u>\u041c\u0430\u0442\u044c\u0435 \u041d\u0430\u043f\u043f\u043e\u043b\u0438 (Matthieu Nappoli)<\/u><\/a>, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044e <a href=\"https:\/\/bref.sh\/\"><u>Bref.sh<\/u><\/a>, \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0449\u0435\u0439 \u0435\u043c\u0443 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/brefphp\/bref\"><u>\u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c<\/u><\/a>.&nbsp;<\/p>\n<p>Bref \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u0442\u044c PHP-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 <a href=\"https:\/\/aws.amazon.com\/\"><u>AWS<\/u><\/a> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 <a href=\"https:\/\/aws.amazon.com\/lambda\/\"><u>AWS Lambda<\/u><\/a>.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 kernel.php \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043b\u043e\u0433\u043e\u0432:<\/p>\n<pre><code class=\"php\">&lt;?php     \/\/ Kernel.php     public function getLogDir(): string     {         if (getenv('LAMBDA_TASK_ROOT') !== false) {             return '\/tmp\/log\/';         }          return parent::getLogDir();     }      public function getCacheDir()     {         if (getenv('LAMBDA_TASK_ROOT') !== false) {             return '\/tmp\/cache\/'.$this-&gt;environment;         }          return parent::getCacheDir();     }<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Serverless <a href=\"https:\/\/bref.sh\/docs\/installation.html\"><u>(\u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e)<\/u><\/a>:<\/p>\n<pre><code class=\"php\">$ npm install -g serverless $ serverless config credentials --provider aws --key  --secret $ composer require bref\/bref<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0432 \u0444\u0430\u0439\u043b\u0435 serverless.yaml:<\/p>\n<pre><code class=\"php\">service: notifier-linkedin-api  provider:     name: aws     region: eu-west-3     runtime: provided     environment: # env vars         APP_ENV: prod         LINKEDIN_DSN: YOUR_DSN   plugins:     - .\/vendor\/bref\/bref  functions:     website:         handler: public\/index.php # bootstrap          layers:             - ${bref:layer.php-73-fpm} # https:\/\/bref.sh\/docs\/runtimes\/index.html#usage          timeout: 28 # Timeout to stop the compute time         events:             - http: 'POST \/contents' # Only POST to \/contents are allowed  package:     exclude:         - 'tests\/**' view rawserverless.yaml hosted with \u200b by GitHub<\/code><\/pre>\n<p>\u0420\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u0435\u043c!<\/p>\n<pre><code>$ serverless deploy Serverless: Packaging service... Serverless: Excluding development dependencies... Serverless: Uploading CloudFormation file to S3... Serverless: Uploading artifacts... Serverless: Uploading service notifier-linkedin-api.zip file to S3 (10.05 MB)... Serverless: Validating template... Serverless: Updating Stack... Serverless: Checking Stack update progress... .................... Serverless: Stack update finished... Service Information service: notifier-linkedin-api stage: dev region: eu-west-3 stack: notifier-linkedin-api-dev resources: 15 api keys:   None endpoints:   POST - https:\/\/xxx.execute-api.eu-west-3.amazonaws.com\/dev\/contents functions:   website: notifier-linkedin-api-dev-website layers:   None Serverless: Removing old service artifacts from S3... Serverless: Run the \"serverless\" command to setup monitoring, troubleshooting and testing.<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442 \u0432 AWS Lambda, \u0430 API \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>https:\/\/xxx.execute-api.eu-west-3.amazonaws.com\/dev\/contents<\/code>.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<hr>\n<blockquote>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/KqEN\/\"><strong>&#171;Symfony Framework&#187;<\/strong><\/a>. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u043a\u0443\u0440\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043d\u0430 <a href=\"https:\/\/otus.pw\/CAZa\/\">\u0434\u0435\u043d\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0432\u0435\u0440\u0435\u0439<\/a> \u043e\u043d\u043b\u0430\u0439\u043d, \u0433\u0434\u0435 \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/blockquote>\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\/otus\/blog\/562392\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/562392\/<\/a><br \/><\/br><\/br><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-324810","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324810","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=324810"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324810\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}