{"id":479689,"date":"2026-05-14T08:29:18","date_gmt":"2026-05-14T08:29:18","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=479689"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=479689","title":{"rendered":"\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Laravel + Centrifugo: \u043a\u0442\u043e \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0432 real-time \u0441\u0438\u0441\u0442\u0435\u043c\u0435"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u00a0<a href=\"https:\/\/habr.com\/ru\/articles\/1034780\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>\u00a0\u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0447\u0442\u043e Real-time \u043d\u0430 Laravel-\u0441\u0430\u0439\u0442\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u0430\u043c, \u0433\u0434\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b: \u043d\u043e\u0432\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u0441\u043c\u0435\u043d\u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043a\u0430\u0437\u0430, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0447\u0430\u0442\u0435, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443\u0436\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430, \u0430 polling \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 backend. \u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Centrifugo \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 WebSocket-\u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u044f\u0434\u043e\u043c \u0441 Laravel-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 Laravel + Centrifugo: \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 Laravel, \u043a\u0430\u043a\u0443\u044e \u0440\u043e\u043b\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 Centrifugo, \u043a\u0430\u043a frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a real-time \u043a\u0430\u043d\u0430\u043b\u0443 \u0438 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0438\u043f\u043e\u0432\u043e\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c Laravel \u0438 Centrifugo<\/h3>\n<p>Laravel \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c backend-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0418\u043c\u0435\u043d\u043d\u043e Laravel \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0448\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0438 \u043a\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u044d\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c.<\/p>\n<p>Centrifugo \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443. \u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 WebSocket-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043d\u0430\u043b\u044b, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c. \u042d\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u0430 Laravel \u0438 \u043d\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 backend \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439. Centrifugo \u2014 real-time \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442 Laravel \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u0415\u0441\u043b\u0438 \u0441\u043c\u0435\u0448\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 WebSocket-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0445\u0440\u0443\u043f\u043a\u043e\u0439. \u041d\u0430 \u0434\u0435\u043c\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0431\u043e\u0434\u0440\u043e. \u0412 production \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u0430\u044f \u0430\u0440\u0445\u0435\u043e\u043b\u043e\u0433\u0438\u044f: \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043d\u0435 \u0441\u0432\u043e\u0451 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u0430\u0442\u0443\u0441 \u043f\u0440\u0438\u0448\u0451\u043b \u0440\u0430\u043d\u044c\u0448\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u0435, \u043f\u043e\u0447\u0435\u043c\u0443 frontend \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 API \u0435\u0449\u0451 \u0441\u0442\u0430\u0440\u044b\u0435.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Laravel Centrifugo \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0434\u0435\u0435: Laravel \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u0441\u0442\u0438\u043d\u044b, \u0430 Centrifugo \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<h3>\u041e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b Laravel + Centrifugo<\/h3>\n<p>\u0412 real-time \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0441\u0430\u0439\u0442\u0430 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043b\u043e\u044f:<\/p>\n<ol>\n<li>\n<p><strong>Laravel backend<\/strong>\u00a0\u2014 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430, \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Centrifugo server<\/strong>\u00a0\u2014 WebSocket-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043d\u0430\u043b\u044b, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>Frontend client<\/strong>\u00a0\u2014 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a Centrifugo, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u044b, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/66c\/29a\/1cb\/66c29a1cbf7e27fef201538cfc848895.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Laravel \u0438 Centrifugo \u0434\u043b\u044f real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435\" title=\"\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0441\u0445\u0435\u043c\u0430 real-time \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: Laravel \u043e\u0442\u0434\u0430\u0451\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u043d\u0430\u043b, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.\" width=\"574\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/66c\/29a\/1cb\/66c29a1cbf7e27fef201538cfc848895.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/66c\/29a\/1cb\/66c29a1cbf7e27fef201538cfc848895.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0441\u0445\u0435\u043c\u0430 real-time \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: Laravel \u043e\u0442\u0434\u0430\u0451\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u043d\u0430\u043b, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u043e\u043b\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043b\u043e\u044f. HTTP \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. WebSocket \u0447\u0435\u0440\u0435\u0437 Centrifugo \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0437\u0430\u043a\u0430\u0437\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u043c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c:<\/p>\n<pre><code>{  \"id\": 7821,  \"status\": \"pending\",  \"amount\": 1500}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e frontend \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 real-time \u043a\u0430\u043d\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u043b\u0430\u0447\u0435\u043d, Laravel \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Centrifugo, \u0430 Centrifugo \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0435\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 WebSocket.<\/p>\n<h3>Laravel \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f<\/h3>\n<p>Laravel \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00bb \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 WebSocket. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0433\u043b\u0443\u0431\u0436\u0435. Backend \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430, \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043e\u043f\u043b\u0430\u0442\u043e\u0439 \u0437\u0430\u043a\u0430\u0437\u0430. \u041f\u043b\u0430\u0442\u0451\u0436\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 webhook. Laravel \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043a\u0430\u0437, \u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0443\u0441 \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0<code>OrderStatusChanged<\/code>.<\/p>\n<p>\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<pre><code>namespace App\\Http\\Controllers\\Payment;use App\\Events\\OrderStatusChanged;use App\\Models\\Order;use Illuminate\\Http\\JsonResponse;use Illuminate\\Http\\Request;class PaymentWebhookController{    public function __invoke(Request $request): JsonResponse    {        $order = Order::query()            -&gt;where('payment_id', $request-&gt;input(key: 'payment_id'))            -&gt;firstOrFail();        $order-&gt;update([            'status' =&gt; 'paid',        ]);        event(new OrderStatusChanged(            orderId: $order-&gt;id,            userId: $order-&gt;user_id,            status: 'paid',        ));        return response()-&gt;json(data: [            'success' =&gt; true,        ]);    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0434\u0435\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 webhook, \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a. \u041d\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043d: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435.<\/p>\n<p>\u0421\u0430\u043c\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c:<\/p>\n<pre><code>namespace App\\Events;class OrderStatusChanged{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043e Centrifugo. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c. \u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u043a\u0442 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438: \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u0410 \u043a\u0443\u0434\u0430 \u043f\u043e\u0442\u043e\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u0443\u0439\u0434\u0451\u0442 \u2014 \u0432 Centrifugo, email, \u043b\u043e\u0433 \u0430\u0443\u0434\u0438\u0442\u0430 \u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u2014 \u0440\u0435\u0448\u0430\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<\/p>\n<h3>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 Centrifugo \u0447\u0435\u0440\u0435\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u044c<\/h3>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Centrifugo \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 HTTP-\u0432\u0445\u043e\u0434, \u0430 \u043d\u0435 \u0437\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 real-time \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Laravel Events, listeners \u0438 queue jobs.<\/p>\n<p>Listener \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c:<\/p>\n<pre><code>namespace App\\Listeners;use App\\Events\\OrderStatusChanged;use App\\Jobs\\PublishOrderStatusChangedToRealtime;class SendOrderStatusChangedToRealtime{    public function handle(OrderStatusChanged $event): void    {        PublishOrderStatusChangedToRealtime::dispatch(            orderId: $event-&gt;orderId,            userId: $event-&gt;userId,            status: $event-&gt;status,        )-&gt;afterCommit();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434\u00a0<code>afterCommit()<\/code>\u00a0\u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u0435\u043d. Real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0439\u0442\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u043d\u0430\u0447\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0435\u00a0<code>paid<\/code>, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0437\u0430\u043a\u0430\u0437 \u0447\u0435\u0440\u0435\u0437 API \u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441\u00a0<code>pending<\/code>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u00ab\u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0431\u0430\u0433\u0430\u00bb, \u0445\u043e\u0442\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430: \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0431\u044b\u043b\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0430\u043d\u043e.<\/p>\n<p>Job \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code>namespace App\\Jobs;use App\\Services\\Realtime\\CentrifugoPublisher;use Illuminate\\Contracts\\Queue\\ShouldQueue;class PublishOrderStatusChangedToRealtime implements ShouldQueue{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }    public function handle(CentrifugoPublisher $publisher): void    {        $publisher-&gt;publish(            channel: '$users:' . $this-&gt;userId,            data: [                'type' =&gt; 'order.status.changed',                'orderId' =&gt; $this-&gt;orderId,                'status' =&gt; $this-&gt;status,            ],        );    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0430\u0451\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 Centrifugo. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0435. \u041b\u043e\u0433\u0438\u043a\u0443 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c retry, \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u043e\u0433\u0438 \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<\/p>\n<h3>Centrifugo \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 WebSocket, \u043a\u0430\u043d\u0430\u043b\u044b \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/h3>\n<p>Centrifugo \u0432 \u044d\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041e\u043d \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043f\u043e\u0447\u0435\u043c\u0443 \u0437\u0430\u043a\u0430\u0437 \u0441\u0442\u0430\u043b \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u043d\u044b\u043c, \u043a\u0442\u043e \u043e\u043f\u043b\u0430\u0442\u0438\u043b \u0441\u0447\u0451\u0442 \u0438 \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u043d\u0430\u043b.<\/p>\n<p>\u041a\u0430\u043d\u0430\u043b \u2014 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c real-time \u043e\u0431\u043c\u0435\u043d\u0430. Frontend \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u043d\u0430\u043b, \u0430 backend \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0442\u0443\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u0430\u043d\u0430\u043b\u043e\u0432:<\/p>\n<pre><code>$users:15$orders:7821$admin:orderschat:room:45dashboard:payments<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043a\u0430\u043d\u0430\u043b\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043d\u0430\u043b\u00a0<code>$users:15<\/code>\u00a0\u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0412 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u0432 \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0444\u043e\u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<p>Laravel \u043c\u043e\u0436\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 Centrifugo \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<pre><code>namespace App\\Services\\Realtime;use Illuminate\\Support\\Facades\\Http;class CentrifugoPublisher{    public function publish(        string $channel,        array $data,    ): void {        Http::withHeaders(headers: [            'Authorization' =&gt; 'apikey ' . config('services.centrifugo.api_key'),        ])-&gt;post(            url: config('services.centrifugo.api_url') . '\/api\/publish',            data: [                'channel' =&gt; $channel,                'data' =&gt; $data,            ],        )-&gt;throw();    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0442\u044c HTTP-\u0432\u044b\u0437\u043e\u0432\u044b Centrifugo \u043f\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c, \u043c\u043e\u0434\u0435\u043b\u044f\u043c \u0438 listener-\u0430\u043c. \u041e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u043e\u0449\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c, \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0438 \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 payload. \u0412 WebSocket-\u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u044e Eloquent-\u043c\u043e\u0434\u0435\u043b\u044c. \u042d\u0442\u043e \u0440\u0438\u0441\u043a \u0443\u0442\u0435\u0447\u043a\u0438 \u043b\u0438\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 backend \u0438 frontend.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435:<\/p>\n<pre><code>{  \"type\": \"order.status.changed\",  \"orderId\": 7821,  \"status\": \"paid\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 frontend \u043d\u0443\u0436\u043d\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 HTTP API. Real-time \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438, HTTP \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443.<\/p>\n<h3>Frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/h3>\n<p>Frontend \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 Laravel, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u0430\u043d\u0430\u043b\u044b. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u043d \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>import { Centrifuge } from 'centrifuge';const centrifuge = new Centrifuge('wss:\/\/example.com\/connection\/websocket', {    getToken: async function () {        const response = await fetch('\/realtime\/connection-token', {            headers: {                Accept: 'application\/json',            },            credentials: 'same-origin',        });        const data = await response.json();        return data.token;    },});const userChannel = '$users:15';const subscription = centrifuge.newSubscription(userChannel, {    getToken: async function () {        const response = await fetch('\/realtime\/subscription-token', {            method: 'POST',            headers: {                Accept: 'application\/json',                'Content-Type': 'application\/json',            },            credentials: 'same-origin',            body: JSON.stringify({                channel: userChannel,            }),        });        const data = await response.json();        return data.token;    },});subscription.on('publication', function (context) {    if (context.data.type === 'order.status.changed') {        updateOrderStatus(            context.data.orderId,            context.data.status,        );    }});subscription.subscribe();centrifuge.connect();<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f, \u043d\u043e \u0432 production \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u0438 \u043a\u0430\u043d\u0430\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0448\u043b\u043e \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u00a0<code>'$users:15'<\/code>\u00a0\u043d\u0430\u00a0<code>'$users:16'<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 Laravel \u043e\u0431\u044f\u0437\u0430\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c token \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f: Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435<\/h3>\n<p>\u0421\u043e\u0431\u0435\u0440\u0451\u043c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043a\u0440\u044b\u043b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0437\u0430\u043a\u0430\u0437\u0430. Laravel \u043e\u0442\u0434\u0430\u043b \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e HTTP. \u0417\u0430\u043a\u0430\u0437 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u0443\u0441\u0435\u00a0<code>pending<\/code>. Frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f \u043a Centrifugo \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b\u0441\u044f \u043d\u0430 \u043a\u0430\u043d\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u00a0<code>$users:15<\/code>.<\/p>\n<p>\u041f\u043e\u0442\u043e\u043c \u043f\u043b\u0430\u0442\u0451\u0436\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0430 webhook. Laravel \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u0437\u0430\u043f\u0440\u043e\u0441, \u043d\u0430\u0448\u0451\u043b \u0437\u0430\u043a\u0430\u0437, \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0441\u0442\u0430\u0442\u0443\u0441 \u043d\u0430\u00a0<code>paid<\/code>, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u0437\u0434\u0430\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0<code>OrderStatusChanged<\/code>.<\/p>\n<p>Listener \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u0441\u043b\u0435 commit \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. Job \u0432\u044b\u0437\u0432\u0430\u043b\u00a0<code>CentrifugoPublisher<\/code>\u00a0\u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>{  \"channel\": \"$users:15\",  \"data\": {    \"type\": \"order.status.changed\",    \"orderId\": 7821,    \"status\": \"paid\"  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Centrifugo \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c, \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u00a0<code>$users:15<\/code>. \u0415\u0441\u043b\u0438 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043a\u043b\u0430\u0434\u043e\u043a, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u043a\u043b\u0430\u0434\u043a\u0438. Frontend \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441 \u00ab\u041e\u0436\u0438\u0434\u0430\u0435\u0442 \u043e\u043f\u043b\u0430\u0442\u044b\u00bb \u043d\u0430 \u00ab\u041e\u043f\u043b\u0430\u0447\u0435\u043d\u00bb.<\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439:<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/893\/26a\/4a4\/89326a4a40ffaaa2054a3dcd964fe83b.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 webhook \u043f\u043b\u0430\u0442\u0435\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0447\u0435\u0440\u0435\u0437 Laravel, \u043e\u0447\u0435\u0440\u0435\u0434\u044c, Centrifugo \u0438 WebSocket\" title=\"\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f: webhook \u043f\u043b\u0430\u0442\u0451\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 Laravel, backend \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, queue job \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 Centrifugo, \u0430 frontend \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 WebSocket.\" width=\"581\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/893\/26a\/4a4\/89326a4a40ffaaa2054a3dcd964fe83b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/893\/26a\/4a4\/89326a4a40ffaaa2054a3dcd964fe83b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f: webhook \u043f\u043b\u0430\u0442\u0451\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 Laravel, backend \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430, \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, queue job \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 Centrifugo, \u0430 frontend \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 WebSocket.<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b real-time Laravel \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u043d\u0430\u0431\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 WebSocket-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<ul>\n<li>\n<p>Laravel \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u0441\u0442\u0438\u043d\u044b. \u0412\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. WebSocket-\u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e.<\/p>\n<\/li>\n<li>\n<p>Centrifugo \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043e\u043c. \u0412 \u043d\u0451\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0441\u043b\u0435 commit \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0440\u0438\u0441\u043a \u0440\u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0438 API.<\/p>\n<\/li>\n<li>\n<p>Payload \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c. \u041f\u043e\u043b\u043d\u0430\u044f Eloquent-\u043c\u043e\u0434\u0435\u043b\u044c \u0432 real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0438 &#8212; \u043f\u043b\u043e\u0445\u0430\u044f \u0438\u0434\u0435\u044f. \u041b\u0443\u0447\u0448\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>Frontend \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 HTTP. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0442\u0435\u0440\u044f\u043b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0437\u0430\u043a\u0440\u044b\u043b \u043d\u043e\u0443\u0442\u0431\u0443\u043a, \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u0438\u0437 \u0441\u043f\u044f\u0449\u0435\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443 Laravel.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Laravel + Centrifugo \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u044f\u0441\u043d\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. Laravel \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. Centrifugo \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 WebSocket-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043d\u0430\u043b\u044b, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. Frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c real-time \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442 \u0431\u0435\u0437 \u0440\u0430\u0437\u0440\u0443\u0448\u0435\u043d\u0438\u044f backend-\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. Laravel \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u0441\u0442\u0438\u043d\u044b, \u0430 Centrifugo \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c real-time \u0441\u043b\u043e\u0435\u043c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<\/p>\n<p>\u0414\u043b\u044f Laravel-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e: \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 Events, listeners, jobs, \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0439 \u0441\u043b\u043e\u0439. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 real-time \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u0433\u0440\u0443\u0448\u043a\u043e\u0439 \u0441\u0431\u043e\u043a\u0443, \u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e web-\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.<\/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\/articles\/1035046\/\">https:\/\/habr.com\/ru\/articles\/1035046\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u00a0\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438\u00a0\u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0447\u0442\u043e Real-time \u043d\u0430 Laravel-\u0441\u0430\u0439\u0442\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u0430\u043c, \u0433\u0434\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b: \u043d\u043e\u0432\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u0441\u043c\u0435\u043d\u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043a\u0430\u0437\u0430, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0447\u0430\u0442\u0435, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443\u0436\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430, \u0430 polling \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 backend. \u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Centrifugo \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 WebSocket-\u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u044f\u0434\u043e\u043c \u0441 Laravel-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 Laravel + Centrifugo: \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 Laravel, \u043a\u0430\u043a\u0443\u044e \u0440\u043e\u043b\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 Centrifugo, \u043a\u0430\u043a frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a real-time \u043a\u0430\u043d\u0430\u043b\u0443 \u0438 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0438\u043f\u043e\u0432\u043e\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0437\u0430\u043a\u0430\u0437\u0430.\u0417\u0430\u0447\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c Laravel \u0438 CentrifugoLaravel \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c backend-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0418\u043c\u0435\u043d\u043d\u043e Laravel \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0448\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0438 \u043a\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u044d\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c.Centrifugo \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443. \u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 WebSocket-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043d\u0430\u043b\u044b, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c. \u042d\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u0430 Laravel \u0438 \u043d\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 backend \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439. Centrifugo \u2014 real-time \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0442 Laravel \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430.\u0422\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u0415\u0441\u043b\u0438 \u0441\u043c\u0435\u0448\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 WebSocket-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0445\u0440\u0443\u043f\u043a\u043e\u0439. \u041d\u0430 \u0434\u0435\u043c\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0431\u043e\u0434\u0440\u043e. \u0412 production \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u0430\u044f \u0430\u0440\u0445\u0435\u043e\u043b\u043e\u0433\u0438\u044f: \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043d\u0435 \u0441\u0432\u043e\u0451 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u0430\u0442\u0443\u0441 \u043f\u0440\u0438\u0448\u0451\u043b \u0440\u0430\u043d\u044c\u0448\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u0435, \u043f\u043e\u0447\u0435\u043c\u0443 frontend \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 API \u0435\u0449\u0451 \u0441\u0442\u0430\u0440\u044b\u0435.\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Laravel Centrifugo \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0434\u0435\u0435: Laravel \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0438\u0441\u0442\u0438\u043d\u044b, \u0430 Centrifugo \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.\u041e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b Laravel + Centrifugo\u0412 real-time \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0441\u0430\u0439\u0442\u0430 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043b\u043e\u044f:Laravel backend\u00a0\u2014 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430, \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043e\u0447\u0435\u0440\u0435\u0434\u0438.Centrifugo server\u00a0\u2014 WebSocket-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043d\u0430\u043b\u044b, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.Frontend client\u00a0\u2014 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a Centrifugo, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u044b, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0441\u0445\u0435\u043c\u0430 real-time \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: Laravel \u043e\u0442\u0434\u0430\u0451\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u043d\u0430\u043b, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u043e\u043b\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043b\u043e\u044f. HTTP \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. WebSocket \u0447\u0435\u0440\u0435\u0437 Centrifugo \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0437\u0430\u043a\u0430\u0437\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u043c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c:{  &#171;id&#187;: 7821,  &#171;status&#187;: &#171;pending&#187;,  &#171;amount&#187;: 1500}\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e frontend \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 real-time \u043a\u0430\u043d\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u043b\u0430\u0447\u0435\u043d, Laravel \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Centrifugo, \u0430 Centrifugo \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0435\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 WebSocket.Laravel \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044fLaravel \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00bb \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 WebSocket. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0433\u043b\u0443\u0431\u0436\u0435. Backend \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430, \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435.\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043e\u043f\u043b\u0430\u0442\u043e\u0439 \u0437\u0430\u043a\u0430\u0437\u0430. \u041f\u043b\u0430\u0442\u0451\u0436\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 webhook. Laravel \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043a\u0430\u0437, \u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0443\u0441 \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u00a0OrderStatusChanged.\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:namespace App\\Http\\Controllers\\Payment;use App\\Events\\OrderStatusChanged;use App\\Models\\Order;use Illuminate\\Http\\JsonResponse;use Illuminate\\Http\\Request;class PaymentWebhookController{    public function __invoke(Request $request): JsonResponse    {        $order = Order::query()            -&gt;where(&#8216;payment_id&#8217;, $request-&gt;input(key: &#8216;payment_id&#8217;))            -&gt;firstOrFail();        $order-&gt;update([            &#8216;status&#8217; =&gt; &#8216;paid&#8217;,        ]);        event(new OrderStatusChanged(            orderId: $order-&gt;id,            userId: $order-&gt;user_id,            status: &#8216;paid&#8217;,        ));        return response()-&gt;json(data: [            &#8216;success&#8217; =&gt; true,        ]);    }}\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0434\u0435\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 webhook, \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a. \u041d\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043d: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 Laravel \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435.\u0421\u0430\u043c\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c:namespace App\\Events;class OrderStatusChanged{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }}\u0422\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043e Centrifugo. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c. \u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u043a\u0442 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438: \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u0410 \u043a\u0443\u0434\u0430 \u043f\u043e\u0442\u043e\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u0443\u0439\u0434\u0451\u0442 \u2014 \u0432 Centrifugo, email, \u043b\u043e\u0433 \u0430\u0443\u0434\u0438\u0442\u0430 \u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u2014 \u0440\u0435\u0448\u0430\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 Centrifugo \u0447\u0435\u0440\u0435\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u041f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Centrifugo \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 HTTP-\u0432\u0445\u043e\u0434, \u0430 \u043d\u0435 \u0437\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 real-time \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Laravel Events, listeners \u0438 queue jobs.Listener \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c:namespace App\\Listeners;use App\\Events\\OrderStatusChanged;use App\\Jobs\\PublishOrderStatusChangedToRealtime;class SendOrderStatusChangedToRealtime{    public function handle(OrderStatusChanged $event): void    {        PublishOrderStatusChangedToRealtime::dispatch(            orderId: $event-&gt;orderId,            userId: $event-&gt;userId,            status: $event-&gt;status,        )-&gt;afterCommit();    }}\u041c\u0435\u0442\u043e\u0434\u00a0afterCommit()\u00a0\u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u0435\u043d. Real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0439\u0442\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u043d\u0430\u0447\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0435\u00a0paid, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0437\u0430\u043a\u0430\u0437 \u0447\u0435\u0440\u0435\u0437 API \u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441\u00a0pending. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u00ab\u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0431\u0430\u0433\u0430\u00bb, \u0445\u043e\u0442\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430: \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0431\u044b\u043b\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0430\u043d\u043e.Job \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:namespace App\\Jobs;use App\\Services\\Realtime\\CentrifugoPublisher;use Illuminate\\Contracts\\Queue\\ShouldQueue;class PublishOrderStatusChangedToRealtime implements ShouldQueue{    public function __construct(        public readonly int $orderId,        public readonly int $userId,        public readonly string $status,    ) {    }    public function handle(CentrifugoPublisher $publisher): void    {        $publisher-&gt;publish(            channel: &#8216;$users:&#8217; . $this-&gt;userId,            data: [                &#8216;type&#8217; =&gt; &#8216;order.status.changed&#8217;,                &#8216;orderId&#8217; =&gt; $this-&gt;orderId,                &#8216;status&#8217; =&gt; $this-&gt;status,            ],        );    }}\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0430\u0451\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 Centrifugo. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0435. \u041b\u043e\u0433\u0438\u043a\u0443 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043f\u0440\u043e\u0449\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c retry, \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u043e\u0433\u0438 \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b real-time \u0441\u043e\u0431\u044b\u0442\u0438\u0439.Centrifugo \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 WebSocket, \u043a\u0430\u043d\u0430\u043b\u044b \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439Centrifugo \u0432 \u044d\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041e\u043d \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043f\u043e\u0447\u0435\u043c\u0443 \u0437\u0430\u043a\u0430\u0437 \u0441\u0442\u0430\u043b \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u043d\u044b\u043c, \u043a\u0442\u043e \u043e\u043f\u043b\u0430\u0442\u0438\u043b \u0441\u0447\u0451\u0442 \u0438 \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u043d\u0430\u043b.\u041a\u0430\u043d\u0430\u043b \u2014 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c real-time \u043e\u0431\u043c\u0435\u043d\u0430. Frontend \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u043d\u0430\u043b, \u0430 backend \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0442\u0443\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u0430\u043d\u0430\u043b\u043e\u0432:$users:15$orders:7821$admin:orderschat:room:45dashboard:payments\u0414\u043b\u044f \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043a\u0430\u043d\u0430\u043b\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043d\u0430\u043b\u00a0$users:15\u00a0\u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0412 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u0432 \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0444\u043e\u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.Laravel \u043c\u043e\u0436\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 Centrifugo \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441:namespace App\\Services\\Realtime;use Illuminate\\Support\\Facades\\Http;class CentrifugoPublisher{    public function publish(        string $channel,        array $data,    ): void {        Http::withHeaders(headers: [            &#8216;Authorization&#8217; =&gt; &#8216;apikey &#8216; . config(&#8216;services.centrifugo.api_key&#8217;),        ])-&gt;post(            url: config(&#8216;services.centrifugo.api_url&#8217;) . &#8216;\/api\/publish&#8217;,            data: [                &#8216;channel&#8217; =&gt; $channel,                &#8216;data&#8217; =&gt; $data,            ],        )-&gt;throw();    }}\u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0442\u044c HTTP-\u0432\u044b\u0437\u043e\u0432\u044b Centrifugo \u043f\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c, \u043c\u043e\u0434\u0435\u043b\u044f\u043c \u0438 listener-\u0430\u043c. \u041e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u043e\u0449\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c, \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0438 \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0442\u0435\u0441\u0442\u0430\u043c\u0438.\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 payload. \u0412 WebSocket-\u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u044e Eloquent-\u043c\u043e\u0434\u0435\u043b\u044c. \u042d\u0442\u043e \u0440\u0438\u0441\u043a \u0443\u0442\u0435\u0447\u043a\u0438 \u043b\u0438\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 backend \u0438 frontend.\u041b\u0443\u0447\u0448\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435:{  &#171;type&#187;: &#171;order.status.changed&#187;,  &#171;orderId&#187;: 7821,  &#171;status&#187;: &#171;paid&#187;}\u0415\u0441\u043b\u0438 frontend \u043d\u0443\u0436\u043d\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 HTTP API. Real-time \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438, HTTP \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443.Frontend \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441Frontend \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 Laravel, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a Centrifugo \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u0430\u043d\u0430\u043b\u044b. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u043d \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:import { Centrifuge } from &#8216;centrifuge&#8217;;const centrifuge = new Centrifuge(&#8216;wss:\/\/example.com\/connection\/websocket&#8217;, {    getToken: async function () {        const response = await fetch(&#8216;\/realtime\/connection-token&#8217;, {            headers: {                Accept: &#8216;application\/json&#8217;,            },            credentials: &#8216;same-origin&#8217;,        });        const data = await response.json();        return data.token;    },});const userChannel = &#8216;$users:15&#8217;;const subscription = centrifuge.newSubscription(userChannel, {    getToken: async function () {        const response = await fetch(&#8216;\/realtime\/subscription-token&#8217;, {            method: &#8216;POST&#8217;,            headers: {                Accept: &#8216;application\/json&#8217;,         &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-479689","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479689","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=479689"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479689\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=479689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=479689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=479689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}