채팅 시스템을 위한 Laravel 패키지입니다. 실시간 채팅, 채팅방 관리, 사용자 관리 등의 기능을 제공합니다.
- 공개/비공개 채팅방 생성
- 비밀번호 보호 채팅방
- 채팅방 타입 (public, private, group)
- 최대 참여자 수 제한
- 채팅방 검색 및 필터링
- 실시간 메시지 전송/수신
- 메시지 타입 지원 (text, image, file, system)
- 메시지 읽음 상태 추적
- 메시지 삭제 (관리자)
- 샤딩된 사용자 시스템 지원 (user_0xx 패턴)
- JWT 인증 연동
- 사용자 차단/해제
- 활동 상태 추적
- 전체 채팅방 관리
- 사용자 관리 및 통계
- 메시지 모니터링
- 시스템 통계 및 대시보드
composer require jiny/chatconfig/app.php에 서비스 프로바이더를 추가합니다:
'providers' => [
// ...
\Jiny\Chat\ChatServiceProvider::class,
],php artisan migrate --path=vendor/jiny/chat/database/migrationsphp artisan vendor:publish --provider="Jiny\Chat\ChatServiceProvider" --tag="config"config/chat.php 파일에서 채팅 시스템을 구성할 수 있습니다:
return [
// 샤딩 설정
'sharding' => [
'enabled' => config('auth.sharding.enabled', true),
'pattern' => config('auth.sharding.pattern', 'user_%03d'),
'max_shards' => config('auth.sharding.max_shards', 100),
],
// JWT 인증 설정
'jwt' => [
'enabled' => config('auth.jwt.enabled', true),
'secret' => config('auth.jwt.secret'),
'algorithm' => config('auth.jwt.algorithm', 'HS256'),
],
// 채팅방 기본 설정
'room' => [
'max_participants_default' => 100,
'allow_public_rooms' => true,
'allow_private_rooms' => true,
'require_approval' => false,
],
// 메시지 설정
'message' => [
'max_length' => 1000,
'allowed_types' => ['text', 'image', 'file'],
'enable_read_receipts' => true,
],
// 브로드캐스팅 설정
'broadcasting' => [
'enabled' => false,
'connection' => 'pusher',
],
];이 패키지는 Jiny Auth 패키지의 사용자 샤딩 시스템을 사용합니다:
use Jiny\Auth\Facades\Shard;
use Jiny\Auth\Facades\JwtAuth;
// 사용자 정보 조회
$user = Shard::getUser($userUuid);
// JWT 인증
$token = JwtAuth::generateToken($user);
$user = JwtAuth::parseToken($token);패키지는 다음 라우트를 제공합니다:
GET /chat- 채팅 대시보드GET /chat/rooms- 채팅방 목록GET /chat/rooms/create- 채팅방 생성 페이지POST /chat/rooms- 채팅방 생성 처리GET /chat/rooms/{room}- 채팅방 입장POST /chat/rooms/{room}/join- 채팅방 참여DELETE /chat/rooms/{room}/leave- 채팅방 나가기
GET /admin/chat/stats- 채팅 통계GET /admin/chat/rooms- 채팅방 관리GET /admin/chat/users- 사용자 관리GET /admin/chat/messages- 메시지 관리
use Jiny\Chat\Http\Controllers\RoomController;
$controller = new RoomController();
$request = request()->merge([
'title' => '새 채팅방',
'description' => '채팅방 설명',
'type' => 'public',
'is_public' => true,
'allow_join' => true,
]);
$response = $controller->store($request);use Jiny\Chat\Services\MessageService;
$messageService = new MessageService();
$message = $messageService->sendMessage([
'room_id' => 1,
'sender_uuid' => $user->uuid,
'content' => '안녕하세요!',
'type' => 'text'
]);@extends('jiny-site::layouts.app')
@section('content')
<div class="container">
@include('jiny-chat::rooms.list', ['rooms' => $rooms])
</div>
@endsection@extends('jiny-site::layouts.app')
@section('content')
<div class="container">
@livewire('chat.room', ['roomId' => $room->id])
</div>
@endsection실시간 채팅을 위한 브로드캐스팅 설정:
npm install laravel-echo pusher-js// config/broadcasting.php
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true,
],
],
],php artisan queue:work# 전체 테스트
php artisan test
# 채팅 관련 테스트만
php artisan test --filter=Chat
# 특정 테스트 클래스
php artisan test tests/Feature/ChatRoomTest.phpuse Tests\TestCase;
use Jiny\Chat\Models\Room;
class ChatRoomTest extends TestCase
{
public function test_can_create_chat_room()
{
$response = $this->post('/chat/rooms', [
'title' => '테스트 채팅방',
'type' => 'public',
'is_public' => true,
]);
$response->assertStatus(302);
$this->assertDatabaseHas('chat_rooms', [
'title' => '테스트 채팅방'
]);
}
}POST /chat/rooms
Content-Type: application/json
{
"title": "채팅방 제목",
"description": "채팅방 설명",
"type": "public|private|group",
"is_public": true,
"allow_join": true,
"allow_invite": true,
"password": "선택적 비밀번호",
"max_participants": 100
}
POST /chat/rooms/{roomId}/messages
Content-Type: application/json
{
"content": "메시지 내용",
"type": "text|image|file"
}
-
404 에러 발생
- 서비스 프로바이더가 등록되었는지 확인
- 마이그레이션이 실행되었는지 확인
- 라우트 캐시를 클리어:
php artisan route:clear
-
데이터베이스 테이블 없음
php artisan migrate --path=vendor/jiny/chat/database/migrations
-
레이아웃 컴포넌트 오류
- jiny-site 패키지가 설치되었는지 확인
- 올바른 레이아웃을 사용하고 있는지 확인
tail -f storage/logs/laravel.log- 포크하기
- 기능 브랜치 생성 (
git checkout -b feature/amazing-feature) - 변경사항 커밋 (
git commit -m 'Add amazing feature') - 브랜치에 푸시 (
git push origin feature/amazing-feature) - Pull Request 생성
이 패키지는 MIT 라이선스 하에 제공됩니다.
- 이슈: GitHub Issues
- 문서: 패키지 문서
- 커뮤니티: JinyPHP 커뮤니티
- 초기 릴리스
- 기본 채팅방 기능
- 사용자 관리 시스템
- 관리자 대시보드
JinyPHP Team - 더 나은 웹 개발을 위한 Laravel 패키지