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
OPENLOGI Company Profile
hr01
0
67k
Flutter向けPDFビューア、pdfrxのpdfium WASM対応について
espresso3389
0
130
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
50
20k
Delegating the chores of authenticating users to Keycloak
ahus1
0
160
fukabori.fm 出張版: 売上高617億円と高稼働率を陰で支えた社内ツール開発のあれこれ話 / 20250704 Yoshimasa Iwase & Tomoo Morikawa
shift_evolve
PRO
2
7.9k
ゼロからはじめる採用広報
yutadayo
3
970
LangSmith×Webhook連携で実現するプロンプトドリブンCI/CD
sergicalsix
1
240
Tokyo_reInforce_2025_recap_iam_access_analyzer
hiashisan
0
190
What’s new in Android development tools
yanzm
0
320
CDKTFについてざっくり理解する!!~CloudFormationからCDKTFへ変換するツールも作ってみた~
masakiokuda
1
150
Core Audio tapを使ったリアルタイム音声処理のお話
yuta0306
0
190
怖くない!はじめてのClaude Code
shinya337
0
400
Featured
See All Featured
For a Future-Friendly Web
brad_frost
179
9.8k
How to train your dragon (web standard)
notwaldorf
95
6.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Designing Experiences People Love
moore
142
24k
Music & Morning Musume
bryan
46
6.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
4 Signs Your Business is Dying
shpigford
184
22k
Raft: Consensus for Rubyists
vanstee
140
7k
Thoughts on Productivity
jonyablonski
69
4.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
The Straight Up "How To Draw Better" Workshop
denniskardys
234
140k
Why Our Code Smells
bkeepers
PRO
336
57k
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 - ۀҕୗɺϦϞʔτ։ൃ