Skip to content

Commit 9f4777a

Browse files
authored
Laravel 10.x 번역 broadcasting.md & socialite.md (#488)
* docs(broadcasting): [#470] kr/broadcasing.md 번역 * docs(socialite): [#470] kr/socialite.md 번역
1 parent fe775d6 commit 9f4777a

File tree

2 files changed

+57
-43
lines changed

2 files changed

+57
-43
lines changed

kr/broadcasting.md

+47-37
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ The core concepts behind broadcasting are simple: clients connect to named chann
100100
#### Supported Drivers
101101
#### 지원되는 드라이버
102102

103-
By default, Laravel includes two server-side broadcasting drivers for you to choose from: [Pusher Channels](https://pusher.com/channels) and [Ably](https://ably.io). However, community driven packages such as [laravel-websockets](https://beyondco.de/docs/laravel-websockets/getting-started/introduction) and [soketi](https://docs.soketi.app/) provide additional broadcasting drivers that do not require commercial broadcasting providers.
103+
By default, Laravel includes two server-side broadcasting drivers for you to choose from: [Pusher Channels](https://pusher.com/channels) and [Ably](https://ably.com). However, community driven packages such as [laravel-websockets](https://beyondco.de/docs/laravel-websockets/getting-started/introduction) and [soketi](https://docs.soketi.app/) provide additional broadcasting drivers that do not require commercial broadcasting providers.
104104

105-
기본적으로 라라벨에는 [Pusher Channels](https://pusher.com/channels)[Ably](https://ably.io) 중에서 선택할 수 있는 두 가지 서버 측 브로드캐스팅 드라이버가 포함되어 있습니다. 그러나 [laravel-websockets](https://beyondco.de/docs/laravel-websockets/getting-started/introduction)[soketi](https://docs.soketi.app/) 와 같은 커뮤니티 기반 패키지는 상업용 브로드캐스팅 시스템이 필요하지 않은 추가적인 브로드캐스팅 시스템 드라이버를 제공합니다.
105+
기본적으로 라라벨에는 [Pusher Channels](https://pusher.com/channels)[Ably](https://ably.com) 중에서 선택할 수 있는 두 가지 서버 측 브로드캐스팅 드라이버가 포함되어 있습니다. 그러나 [laravel-websockets](https://beyondco.de/docs/laravel-websockets/getting-started/introduction)[soketi](https://docs.soketi.app/) 와 같은 커뮤니티 기반 패키지는 상업용 브로드캐스팅 시스템이 필요하지 않은 추가적인 브로드캐스팅 시스템 드라이버를 제공합니다.
106106

107107
> **Note**
108108
> Before diving into event broadcasting, make sure you have read Laravel's documentation on [events and listeners](/docs/{{version}}/events).
@@ -196,10 +196,16 @@ The [laravel-websockets](https://github.com/beyondcode/laravel-websockets) and [
196196
<a name="ably"></a>
197197
### Ably
198198
### Ably
199+
200+
> **Note**
201+
> The documentation below discusses how to use Ably in "Pusher compatibility" mode. However, the Ably team recommends and maintains a broadcaster and Echo client that is able to take advantage of the unique capabilities offered by Ably. For more information on using the Ably maintained drivers, please [consult Ably's Laravel broadcaster documentation](https://github.com/ably/laravel-broadcaster).
202+
203+
> **Note**
204+
> 아래 문서는 "Pusher 호환" 모드 사용 방법에 대해서 설명합니다. 그러나 Ably 팀 에서는 Ably가 제공하는 고유한 기능을 활용할 수 있는 브로드캐스터 및 Echo 클라이언트를 권장하고 유지 관리합니다. Ably 유지 관리 드라이버 사용에 대한 자세한 내용은 [Ably의 Laravel 브로드캐스터 설명서](https://github.com/ably/laravel-broadcaster)를 참조하십시오.
199205
200-
If you plan to broadcast your events using [Ably](https://ably.io), you should install the Ably PHP SDK using the Composer package manager:
206+
If you plan to broadcast your events using [Ably](https://ably.com), you should install the Ably PHP SDK using the Composer package manager:
201207

202-
[Ably](https://ably.io)를 사용하여 이벤트를 브로드캐스트하려면 Composer 패키지 관리자를 사용하여 Ably PHP SDK를 설치해야 합니다.
208+
[Ably](https://ably.com)를 사용하여 이벤트를 브로드캐스트하려면 Composer 패키지 관리자를 사용하여 Ably PHP SDK를 설치해야 합니다.
203209

204210
```shell
205211
composer require ably/ably-php
@@ -288,10 +294,10 @@ npm run dev
288294
```
289295

290296
> **Note**
291-
> To learn more about compiling your application's JavaScript assets, please consult the documentation on [Laravel Vite](/docs/{{version}}/vite).
297+
> To learn more about compiling your application's JavaScript assets, please consult the documentation on [Vite](/docs/{{version}}/vite).
292298
293299
> **Note**
294-
> 애플리케이션의 JavaScript 자산-assets 컴파일에 대한 자세한 내용은 [Laravel Vite](/docs/{{version}}/vite)에 대한 문서를 참조하세요.
300+
> 애플리케이션의 JavaScript 자산-assets 컴파일에 대한 자세한 내용은 [Vite](/docs/{{version}}/vite)에 대한 문서를 참조하세요.
295301
296302
<a name="using-an-existing-client-instance"></a>
297303
#### Using An Existing Client Instance
@@ -320,6 +326,12 @@ window.Echo = new Echo({
320326
### Ably
321327
### Ably
322328

329+
> **Note**
330+
> The documentation below discusses how to use Ably in "Pusher compatibility" mode. However, the Ably team recommends and maintains a broadcaster and Echo client that is able to take advantage of the unique capabilities offered by Ably. For more information on using the Ably maintained drivers, please [consult Ably's Laravel broadcaster documentation](https://github.com/ably/laravel-broadcaster).
331+
332+
> **Note**
333+
> 아래 문서는 "Pusher 호환" 모드 사용 방법에 대해서 설명합니다. 그러나 Ably 팀 에서는 Ably가 제공하는 고유한 기능을 활용할 수 있는 브로드캐스터 및 Echo 클라이언트를 권장하고 유지 관리합니다. Ably 유지 관리 드라이버 사용에 대한 자세한 내용은 [Ably의 Laravel 브로드캐스터 설명서](https://github.com/ably/laravel-broadcaster)를 참조하십시오.
334+
323335
[Laravel Echo](https://github.com/laravel/echo) is a JavaScript library that makes it painless to subscribe to channels and listen for events broadcast by your server-side broadcasting driver. You may install Echo via the NPM package manager. In this example, we will also install the `pusher-js` package.
324336

325337
[Laravel Echo](https://github.com/laravel/echo) 는 손쉽게 채널을 구독하고, 서버 측 브로드캐스팅 드라이버에서 브로드캐스트하는 이벤트를 수신할 수 있도록 하는 JavaScript 라이브러리입니다. NPM 패키지 관리자를 통해 Echo를 설치할 수 있습니다. 이 예제에서는 `pusher-js` 패키지도 설치합니다.
@@ -369,18 +381,18 @@ npm run dev
369381
```
370382

371383
> **Note**
372-
> To learn more about compiling your application's JavaScript assets, please consult the documentation on [Laravel Vite](/docs/{{version}}/vite).
384+
> To learn more about compiling your application's JavaScript assets, please consult the documentation on [Vite](/docs/{{version}}/vite).
373385
374386
> **Note**
375-
> 애플리케이션의 JavaScript 자산-assets 컴파일에 대한 자세한 내용은 [Laravel Vite](/docs/{{version}}/vite)에 대한 문서를 참조하세요.
387+
> 애플리케이션의 JavaScript 자산-assets 컴파일에 대한 자세한 내용은 [Vite](/docs/{{version}}/vite)에 대한 문서를 참조하세요.
376388
377389
<a name="concept-overview"></a>
378390
## Concept Overview
379391
## 컨셉 개요
380392

381-
Laravel's event broadcasting allows you to broadcast your server-side Laravel events to your client-side JavaScript application using a driver-based approach to WebSockets. Currently, Laravel ships with [Pusher Channels](https://pusher.com/channels) and [Ably](https://ably.io) drivers. The events may be easily consumed on the client-side using the [Laravel Echo](#client-side-installation) JavaScript package.
393+
Laravel's event broadcasting allows you to broadcast your server-side Laravel events to your client-side JavaScript application using a driver-based approach to WebSockets. Currently, Laravel ships with [Pusher Channels](https://pusher.com/channels) and [Ably](https://ably.com) drivers. The events may be easily consumed on the client-side using the [Laravel Echo](#client-side-installation) JavaScript package.
382394

383-
라라벨의 이벤트 브로드캐스팅을 사용하면 WebSocket에 대한 드라이버 기반 접근 방식을 사용하여 서버측 라라벨 이벤트를 클라이언트측 JavaScript 애플리케이션에 브로드캐스트할 수 있습니다. 현재 라라벨은 [Pusher Channels](https://pusher.com/channels)[Ably](https://ably.io) 드라이버와 함께 제공됩니다. 이벤트는 [Laravel Echo](#client-side-installation) JavaScript 패키지를 사용하여 클라이언트 측에서 쉽게 사용할 수 있습니다.
395+
라라벨의 이벤트 브로드캐스팅을 사용하면 WebSocket에 대한 드라이버 기반 접근 방식을 사용하여 서버측 라라벨 이벤트를 클라이언트측 JavaScript 애플리케이션에 브로드캐스트할 수 있습니다. 현재 라라벨은 [Pusher Channels](https://pusher.com/channels)[Ably](https://ably.com) 드라이버와 함께 제공됩니다. 이벤트는 [Laravel Echo](#client-side-installation) JavaScript 패키지를 사용하여 클라이언트 측에서 쉽게 사용할 수 있습니다.
384396

385397
Events are broadcast over "channels", which may be specified as public or private. Any visitor to your application may subscribe to a public channel without any authentication or authorization; however, in order to subscribe to a private channel, a user must be authenticated and authorized to listen on that channel.
386398

@@ -677,7 +689,7 @@ Sometimes you want to broadcast your event only if a given condition is true. Yo
677689

678690
<a name="broadcasting-and-database-transactions"></a>
679691
#### Broadcasting & Database Transactions
680-
#### 브로드캐스팅 및 데이터베이스 거래
692+
#### 브로드캐스팅 및 데이터베이스 트랜잭션
681693

682694
When broadcast events are dispatched within database transactions, they may be processed by the queue before the database transaction has committed. When this happens, any updates you have made to models or database records during the database transaction may not yet be reflected in the database. In addition, any models or database records created within the transaction may not exist in the database. If your event depends on these models, unexpected errors can occur when the job that broadcasts the event is processed.
683695

@@ -785,7 +797,9 @@ Next, we need to define the logic that will actually determine if the currently
785797

786798
다음으로, 현재 인증된 사용자가 주어진 채널을 수신할 수 있는지 여부를 실제로 결정하는 로직을 정의해야 합니다. 이것은 애플리케이션에 포함된 `routes/channels.php` 파일에서 수행됩니다. 이 파일에서 `Broadcast::channel` 메소드를 사용하여 채널 인증 콜백을 등록할 수 있습니다.
787799

788-
Broadcast::channel('orders.{orderId}', function ($user, $orderId) {
800+
use App\Models\User;
801+
802+
Broadcast::channel('orders.{orderId}', function (User $user, int $orderId) {
789803
return $user->id === Order::findOrNew($orderId)->user_id;
790804
});
791805

@@ -806,8 +820,9 @@ Just like HTTP routes, channel routes may also take advantage of implicit and ex
806820
HTTP 경로와 마찬가지로 채널 경로도 암시적 및 명시적 [경로 모델 바인딩](/docs/{{version}}/routing#route-model-binding)을 활용할 수 있습니다. 예를 들어 문자열이나 숫자 주문 ID를 받는 대신 실제 `Order` 모델 인스턴스를 요청할 수 있습니다.
807821

808822
use App\Models\Order;
823+
use App\Models\User;
809824

810-
Broadcast::channel('orders.{order}', function ($user, Order $order) {
825+
Broadcast::channel('orders.{order}', function (User $user, Order $order) {
811826
return $user->id === $order->user_id;
812827
});
813828

@@ -928,7 +943,7 @@ axios.post('/task', task)
928943

929944
However, remember that we also broadcast the task's creation. If your JavaScript application is also listening for this event in order to add tasks to the task list, you will have duplicate tasks in your list: one from the end-point and one from the broadcast. You may solve this by using the `toOthers` method to instruct the broadcaster to not broadcast the event to the current user.
930945

931-
그러나 태스크 생성도 브로드캐스트한다는 것을 기억하십시오. JavaScript 애플리케이션이 작업 목록에 작업을 추가하기 위해 이 이벤트도 수신하는 경우 목록에 중복 작업이 있을 것입니다. 하나는 엔드포인트에서, 다른 하나는 브로드캐스트에서입니다. 브로드캐스터가 현재 사용자에게 이벤트를 브로드캐스트하지 않도록 지시하는 `toOthers` 메서드를 사용하여 이 문제를 해결할 수 있습니다.
946+
그러나 작업의 생성도 브로드캐스트한다는 점을 기억하세요. JavaScript 애플리케이션이 작업 목록에 작업을 추가하기 위해 이 이벤트도 수신 대기 중인 경우, 목록에 엔드포인트의 작업과 브로드캐스트의 작업이 중복될 수 있습니다. 브로드캐스터가 현재 사용자에게 이벤트를 브로드캐스트하지 않도록 지시하는 `toOthers` 메서드를 사용하여 이 문제를 해결할 수 있습니다.
932947

933948
> **Warning**
934949
> Your event must use the `Illuminate\Broadcasting\InteractsWithSockets` trait in order to call the `toOthers` method.
@@ -1104,7 +1119,9 @@ The data returned by the authorization callback will be made available to the pr
11041119

11051120
승인 콜백에 의해 되돌려받는 데이터는 자바스크립트 애플리케이션의 프레젠스 채널 이벤트 수신자들이 사용할 수 있게 될 것입니다. 만약 사용자가 프레젠스 채널에 들어가는 것이 승인되지 않았으면, `false``null`을 되돌려 주어야 합니다.
11061121

1107-
Broadcast::channel('chat.{roomId}', function ($user, $roomId) {
1122+
use App\Models\User;
1123+
1124+
Broadcast::channel('chat.{roomId}', function (User $user, int $roomId) {
11081125
if ($user->canJoinRoom($roomId)) {
11091126
return ['id' => $user->id, 'name' => $user->name];
11101127
}
@@ -1133,7 +1150,7 @@ Echo.join(`chat.${roomId}`)
11331150
console.error(error);
11341151
});
11351152
```
1136-
1153+
<!-- 여기 -->
11371154
The `here` callback will be executed immediately once the channel is joined successfully, and will receive an array containing the user information for all of the other users currently subscribed to the channel. The `joining` method will be executed when a new user joins a channel, while the `leaving` method will be executed when a user leaves the channel. The `error` method will be executed when the authentication endpoint returns a HTTP status code other than 200 or if there is a problem parsing the returned JSON.
11381155

11391156
`here` 콜백은 채널이 성공적으로 연결되면 즉시 실행되며 현재 채널을 구독하고 있는 다른 모든 사용자에 대한 사용자 정보가 포함된 배열을 수신합니다. `joining` 메서드는 새로운 사용자가 채널에 합류할 때 실행되고, `leaving` 메서드는 사용자가 채널을 떠날 때 실행됩니다. `error` 메서드는 인증 엔드포인트가 200이 아닌 HTTP 상태 코드를 반환하거나 반환된 JSON을 구문 분석하는 데 문제가 있는 경우 실행됩니다.
@@ -1237,7 +1254,7 @@ class Post extends Model
12371254

12381255
Once your model includes this trait and defines its broadcast channels, it will begin automatically broadcasting events when a model instance is created, updated, deleted, trashed, or restored.
12391256

1240-
모델에 이 특성-trait이 포함되고 브로드캐스트 채널이 정의되면 모델 인스턴스가 생성, 업데이트, 삭제, 휴지통 또는 복원될 때 이벤트 브로드캐스트가 자동으로 시작됩니다.
1257+
모델에 해당 trait이 포함되고 브로드캐스트 채널이 정의되면 모델 인스턴스가 생성, 업데이트, 삭제, 휴지통 또는 복원될 때 이벤트 브로드캐스트가 자동으로 시작됩니다.
12411258

12421259
In addition, you may have noticed that the `broadcastOn` method receives a string `$event` argument. This argument contains the type of event that has occurred on the model and will have a value of `created`, `updated`, `deleted`, `trashed`, or `restored`. By inspecting the value of this variable, you may determine which channels (if any) the model should broadcast to for a particular event:
12431260

@@ -1247,10 +1264,9 @@ In addition, you may have noticed that the `broadcastOn` method receives a strin
12471264
/**
12481265
* Get the channels that model events should broadcast on.
12491266
*
1250-
* @param string $event
1251-
* @return \Illuminate\Broadcasting\Channel|array
1267+
* @return array<string, array<int, \Illuminate\Broadcasting\Channel|\Illuminate\Database\Eloquent\Model>>
12521268
*/
1253-
public function broadcastOn($event)
1269+
public function broadcastOn(string $event): array
12541270
{
12551271
return match ($event) {
12561272
'deleted' => [],
@@ -1272,11 +1288,8 @@ use Illuminate\Database\Eloquent\BroadcastableModelEventOccurred;
12721288

12731289
/**
12741290
* Create a new broadcastable model event for the model.
1275-
*
1276-
* @param string $event
1277-
* @return \Illuminate\Database\Eloquent\BroadcastableModelEventOccurred
12781291
*/
1279-
protected function newBroadcastableEvent($event)
1292+
protected function newBroadcastableEvent(string $event): BroadcastableModelEventOccurred
12801293
{
12811294
return (new BroadcastableModelEventOccurred(
12821295
$this, $event
@@ -1306,12 +1319,13 @@ use Illuminate\Broadcasting\PrivateChannel;
13061319
/**
13071320
* Get the channels that model events should broadcast on.
13081321
*
1309-
* @param string $event
1310-
* @return \Illuminate\Broadcasting\Channel|array
1322+
* @return array<int, \Illuminate\Broadcasting\Channel>
13111323
*/
1312-
public function broadcastOn($event)
1324+
public function broadcastOn(string $event): array
13131325
{
1314-
return [new PrivateChannel('user.'.$this->id)];
1326+
return [
1327+
new PrivateChannel('user.'.$this->id)
1328+
];
13151329
}
13161330
```
13171331

@@ -1366,11 +1380,8 @@ If you would like, you may define a custom broadcast name and payload by adding
13661380
```php
13671381
/**
13681382
* The model event's broadcast name.
1369-
*
1370-
* @param string $event
1371-
* @return string|null
13721383
*/
1373-
public function broadcastAs($event)
1384+
public function broadcastAs(string $event): string|null
13741385
{
13751386
return match ($event) {
13761387
'created' => 'post.created',
@@ -1381,10 +1392,9 @@ public function broadcastAs($event)
13811392
/**
13821393
* Get the data to broadcast for the model.
13831394
*
1384-
* @param string $event
1385-
* @return array
1395+
* @return array<string, mixed>
13861396
*/
1387-
public function broadcastWith($event)
1397+
public function broadcastWith(string $event): array
13881398
{
13891399
return match ($event) {
13901400
'created' => ['title' => $this->title],
@@ -1395,11 +1405,11 @@ public function broadcastWith($event)
13951405

13961406
<a name="listening-for-model-broadcasts"></a>
13971407
### Listening For Model Broadcasts
1398-
### 모델 브로드캐스팅 듣기
1408+
### 모델 브로드캐스팅 수신
13991409

14001410
Once you have added the `BroadcastsEvents` trait to your model and defined your model's `broadcastOn` method, you are ready to start listening for broadcasted model events within your client-side application. Before getting started, you may wish to consult the complete documentation on [listening for events](#listening-for-events).
14011411

1402-
모델에 `BroadcastsEvents` 특성-trait을 추가하고 모델의 `broadcastOn` 메서드를 정의하면 클라이언트 측 애플리케이션 내에서 브로드캐스트된 모델 이벤트 수신을 시작할 준비가 된 것입니다. 시작하기 전에 [이벤트 수신](#listening-for-events)에 대한 전체 문서를 참조할 수 있습니다.
1412+
모델에 `BroadcastsEvents` trait을 추가하고 모델의 `broadcastOn` 메서드를 정의하면 클라이언트 측 애플리케이션 내에서 브로드캐스트된 모델 이벤트 수신을 시작할 준비가 된 것입니다. 시작하기 전에 [이벤트 수신](#listening-for-events)에 대한 전체 문서를 참조할 수 있습니다.
14031413

14041414
First, use the `private` method to retrieve an instance of a channel, then call the `listen` method to listen for a specified event. Typically, the channel name given to the `private` method should correspond to Laravel's [model broadcasting conventions](#model-broadcasting-conventions).
14051415

0 commit comments

Comments
 (0)