Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Laravel5.5 Broadcastingを使ってみた話
Search
Akiyoshi Tanaka
November 15, 2017
Technology
1
550
Laravel5.5 Broadcastingを使ってみた話
laravel.osaka #12
https://github.com/akkunchoi/laravel-broadcasting-sample-app
Akiyoshi Tanaka
November 15, 2017
Tweet
Share
More Decks by Akiyoshi Tanaka
See All by Akiyoshi Tanaka
Node.jsサーバアプリケーションの 稼働方法 ~基本からDockerまで~
akkunchoi
1
910
TypeScript @Decorator で node.js 開発
akkunchoi
0
67
Other Decks in Technology
See All in Technology
AWS Summit Japan 2025 Community Stage - App workflow automation by AWS Step Functions
matsuihidetoshi
1
290
Oracle Audit Vault and Database Firewall 20 概要
oracle4engineer
PRO
3
1.7k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
910
Delegating the chores of authenticating users to Keycloak
ahus1
0
130
BrainPadプログラミングコンテスト記念LT会2025_社内イベント&問題解説
brainpadpr
1
170
GeminiとNotebookLMによる金融実務の業務革新
abenben
0
240
2025-06-26_Lightning_Talk_for_Lightning_Talks
_hashimo2
2
100
Node-REDのFunctionノードでMCPサーバーの実装を試してみた / Node-RED × MCP 勉強会 vol.1
you
PRO
0
120
25分で解説する「最小権限の原則」を実現するための AWS「ポリシー」大全 / 20250625-aws-summit-aws-policy
opelab
9
1.2k
Amazon ECS & AWS Fargate 運用アーキテクチャ2025 / Amazon ECS and AWS Fargate Ops Architecture 2025
iselegant
17
5.8k
Witchcraft for Memory
pocke
1
500
Model Mondays S2E03: SLMs & Reasoning
nitya
0
170
Featured
See All Featured
How GitHub (no longer) Works
holman
314
140k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Designing for humans not robots
tammielis
253
25k
Building an army of robots
kneath
306
45k
What's in a price? How to price your products and services
michaelherold
246
12k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
The Invisible Side of Design
smashingmag
300
51k
Building Adaptive Systems
keathley
43
2.6k
Scaling GitHub
holman
459
140k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Transcript
Laravel BroadcastingΛͬͯΈͨ laravel.osaka #12 2017-11-15
͢͜ͱ - σϞΞϓϦ - https://github.com/akkunchoi/laravel-broadcasting-sample-app - Laravel Broadcasting ͷઃఆɾ࣮ -
ͬͯΈͯؾ͍ͨ
ࣗݾհ # ໊લ ాதষت / Akiyoshi TANAKA / @akkun_choi #
ॴଐ גࣜձࣾBTree / දऔక / ΤϯδχΞ # ܦྺ PHP(ZF) -> Rails -> node.js -> Laravel(ॳ৺ऀ)
Broadcasting - αʔόʔ͔ΒϢʔβʔʹϦΞϧλΠϜ௨ - WebSocketΛ͏ - Pusher or Socket.io͕༻ҙ͞Ε͍ͯΔ -
ࠓճPusherΛ༻͠·͢
ઃఆํ๏ - ϥΠϒϥϦΛΠϯετʔϧ - BroadcastServiceProviderΛՃ - Pusherઃఆ - .env -
config/broadcasting.php - resources/assets/js/bootstrap.js $ npm install --save laravel-echo pusher-js $ composer require pusher/pusher-php-server "~2.6"
ϒϩʔυΩϟετ͢Δ - ShouldBroadcastΛ࣮͢ΔΠϕϯτΛ࡞ - νϟϯωϧ͕2छྨ͋Δ - PrivateChannel - PresenceChannel (=
PrivateChannel + α) - event() or broadcast() ͰૹΔ broadcast(new UserUpdated($user))->toOthers(); 4IPVME#SPBEDBTUΠϕϯτ
ϒϩʔυΩϟετΛड͚औΔ - laravel-echo const channel = window.Echo.join('channel-name') .here((users) => {
console.log('I'm here'); }) .joining((user) => { console.log('joining user', user); }) .leaving((user) => { console.log('leaving user', user); }) .listen('UserUpdated', (e) => { participants.update(e.user); })
ཹҙ1: ೝূ - ೝূඞཁ - /broadcasting/auth ʹΞΫηε͢Δ - Auth::user() ͰϢʔβʔ͕औಘͰ͖Δඞཁ͕͋Δ
- ͦͷͨΊʹɺࣄલʹAuth::login()͕ඞཁ - PublicChannel͋Γ·ͤΜ - Pusherʹ͋Δ͚ͲɺLaravelʹͳ͍
ཹҙ2: broadcaster # Pusher - socket.ioΑΓָ - 100ಉ࣌ଓɺ200,000ϝοηʔδ/·Ͱແྉ - ड৴ͳ͍͕ɺૹ৴͕͍
- https://dashboard.pusher.com/ # socket.io - redisϫʔΧʔ͕ඞཁ - εέʔϥϏϦςΟ
ཹҙ3: ૹ৴͍ - ։ൃ༻ϏϧτΠϯαʔό - ϓϩηε1ͭͳͷͰɺେྔͷϦΫΤετࡹ͚ͳ͍ - ຊ൪WEBαʔόʔΛஔ͘͜ͱͰղܾ - Pusher
- ૹ৴ͯ͠৴͞ΕΔ·Ͱ1ඵఔ͔͔͍ͬͯΔ - ཁҼ: ௨৴ճ૿, HTTPS, keep aliveແ͠, αʔόʔ͕γϯΨϙʔϧ - ղܾࡦ: pusherͷૹ৴ํ๏Λ͢Δʁ
ͦͷଞ - ࿈ଧରࡦʹ lodash.throttle() this.throttlePost = _.throttle(() => { axios.post('/works',
{count: this.count}); }, 500);
·ͱΊ - BroadcastingΛͬͯσϞΞϓϦΛߏஙͨ͠ - PusherΛͬͯखܰʹϦΞϧλΠϜ௨͕Ͱ͖ͨ - ϦΞϧλΠϜੑΛߴΊΔͳΒɺ͏Ұख͍ؒΔ
։ൃϝϯόʔืूʂ - Laravel - node.js - socket.io - Vue /
React / angular - ۀҕୗɺϦϞʔτ։ൃ