1. Go to this page and download the library: Download techigh/sendgo-notification library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Techigh\SendgoNotification\Attributes\Friend\FriendTalkChannel;
use Techigh\SendgoNotification\Attributes\Friend\FriendTalkMessage;
class NewProductNotification extends Notification
{
use Queueable;
public function via(object $notifiable): array
{
return [FriendTalkChannel::class];
}
public function toFriend(object $notifiable): FriendTalkMessage
{
return FriendTalkMessage::make()
->messageType('FI')
->content("신상품 출시!\n\n{$this->product->name}\n{$this->product->price}원")
->imageUrl($this->product->image_url)
->imageLink($this->product->detail_url)
->buttons([
[
'type' => 'WL',
'name' => '자세히 보기',
'linkMo' => $this->product->detail_url,
'linkPc' => $this->product->detail_url,
],
])
->to([
'contact' => $notifiable->phone,
'name' => $notifiable->name,
])
->at();
}
}
use Techigh\SendgoNotification\Attributes\Sms\SmsChannel;
use Techigh\SendgoNotification\Attributes\Sms\SmsMessage;
class VerificationNotification extends Notification
{
use Queueable;
public function __construct(private readonly string $code) {}
public function via(object $notifiable): array
{
return [SmsChannel::class];
}
public function toSms(object $notifiable): SmsMessage
{
return SmsMessage::make()
->messageType('SMS')
->content("[인증번호] {$this->code} (3분 내 입력)")
->to([
'contact' => $notifiable->phone,
'name' => $notifiable->name,
])
->at();
}
}
return SmsMessage::make()
->messageType('LMS')
->subject('[점검 안내]')
->content('2026-04-01 02:00~06:00 서비스 점검이 예정되어 있습니다.')
->to(['contact' => $notifiable->phone])
->at();
use Techigh\SendgoNotification\Exceptions\SendGoException;
try {
$user->notify(new OrderConfirmedNotification($order->number));
} catch (SendGoException $e) {
$ctx = $e->context();
// $ctx['error_code'] — 에러 코드 (예: 'INVALID_TEMPLATE_CODE')
// $ctx['status'] — HTTP 상태 코드
// $ctx['endpoint'] — 호출 엔드포인트
// $ctx['api_version'] — 사용 중인 API 버전
// $ctx['body'] — 원본 응답 body
logger()->error('SendGo 발송 실패', [
'error_code' => $ctx['error_code'] ?? null,
'status' => $ctx['status'] ?? null,
'message' => $e->getMessage(),
]);
}
use Illuminate\Contracts\Queue\ShouldQueue;
class OrderConfirmedNotification extends Notification implements ShouldQueue
{
use Queueable;
public string $queue = 'notifications';
public int $tries = 3;
public int $backoff = 10;
public function failed(SendGoException $e): void
{
logger()->critical('알림 최종 실패', ['error' => $e->getMessage()]);
}
}
bash
php artisan vendor:publish --tag=sendgo
bash
# 큐 워커 실행
php artisan queue:work --queue=notifications
# Redis 캐시 사용 권장 (다중 워커 환경)
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.