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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Akiyoshi Tanaka
November 15, 2017
Technology
560
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Laravel5.5 Broadcastingを使ってみた話
laravel.osaka #12
https://github.com/akkunchoi/laravel-broadcasting-sample-app
Akiyoshi Tanaka
November 15, 2017
More Decks by Akiyoshi Tanaka
See All by Akiyoshi Tanaka
Node.jsサーバアプリケーションの 稼働方法 ~基本からDockerまで~
akkunchoi
1
950
TypeScript @Decorator で node.js 開発
akkunchoi
0
73
Other Decks in Technology
See All in Technology
トヨタ⽣産⽅式(TPS)⼊⾨
recruitengineers
PRO
3
810
【CEDEC2026】Creative Approaches to Localizing the Dialects and Unique Speech of Umamusume: Pretty Derby Characters in English
cygames
PRO
3
20k
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
240
QAエンジニア起点で進める、SmartHRにおける信頼性向上について
kaomi_wombat
1
140
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
200
制約理論(ToC)入門 2026版
recruitengineers
PRO
8
2.3k
Webアクセシビリティ入門 2026
recruitengineers
PRO
3
570
クラウドセキュリティ入門 ~安全なクラウド利用のための基礎知識~
lhazy
13
11k
え?フロントエンドエンジニアの ワイがインフラも!?
puku0x
1
570
事業価値と Engineering 2026年度版
recruitengineers
PRO
49
23k
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」紹介資料
laysakura
2
9k
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
200
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
Visualization
eitanlees
152
17k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
340
YesSQL, Process and Tooling at Scale
rocio
174
15k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
430
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
New Earth Scene 8
popppiees
3
2.5k
A better future with KSS
kneath
240
18k
How to Ace a Technical Interview
jacobian
281
24k
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 - ۀҕୗɺϦϞʔτ։ൃ