PHPackages                             tolgatasci/chat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. tolgatasci/chat

ActiveLibrary

tolgatasci/chat
===============

Laravel için gelişmiş ve güvenli bir sohbet paketi

12PHP

Since Sep 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tolgatasci/chat-pro)[ Packagist](https://packagist.org/packages/tolgatasci/chat)[ RSS](/packages/tolgatasci-chat/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Features
--------

[](#features)

- **Real-Time Messaging:** Integrated real-time communication with WebSockets and Laravel Echo.
- **Multi-Participant Support:** Create one-on-one and group chats.
- **Flexible Structure:** Easily extendable and customizable, adhering to SOLID principles.
- **Security:** Secure messaging with authorization and validation checks.
- **Customizable:** Full control with publishable configuration and view files.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Laravel 8.x, 9.x, or 10.x
- Composer

Installation
------------

[](#installation)

To add the package to your project, follow the steps below.

### 1. Install the Package with Composer

[](#1-install-the-package-with-composer)

```
composer require tolgatasci/chat
```

### 2. Register the Service Provider and Facade (For Laravel 5.4 and Older Versions)

[](#2-register-the-service-provider-and-facade-for-laravel-54-and-older-versions)

You can skip this step in Laravel 5.5 and above due to automatic package discovery.

```
// config/app.php

'providers' => [
    // ...
    TolgaTasci\Chat\Providers\ChatServiceProvider::class,
],

'aliases' => [
    // ...
    'Chat' => TolgaTasci\Chat\Facades\Chat::class,
],
```

### 3. Publish the Configuration File

[](#3-publish-the-configuration-file)

```
php artisan vendor:publish --provider="TolgaTasci\Chat\Providers\ChatServiceProvider" --tag="config"
```

### 4. Publish and Run Migrations

[](#4-publish-and-run-migrations)

```
php artisan vendor:publish --provider="TolgaTasci\Chat\Providers\ChatServiceProvider" --tag="migrations"

php artisan migrate
```

### 5. Add the Messageable Trait to Your Model

[](#5-add-the-messageable-trait-to-your-model)

Use the Messageable trait in models that you want to participate in messaging.

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use TolgaTasci\Chat\Traits\Messageable;

class User extends Authenticatable
{
    use Messageable;

    // ...
}
```

Usage
-----

[](#usage)

### Creating a Conversation

[](#creating-a-conversation)

You can create a new conversation with two or more participants.

```
use TolgaTasci\Chat\Facades\Chat;

$participants = [$user1, $user2];

$conversation = Chat::createConversation($participants);
```

### Sending a Message

[](#sending-a-message)

To send a message to a conversation:

```
$message = Chat::sendMessage($conversation, $sender, 'Hello!', 'text', ['foo' => 'bar']);
```

- $conversation: The conversation where the message will be sent.
- $sender: The user sending the message.
- 'Hello!': The content of the message.
- 'text': Message type (optional).
- \['foo' =&gt; 'bar'\]: Additional data (optional).

### Retrieving Messages

[](#retrieving-messages)

To retrieve messages in a specific conversation:

```
$messages = Chat::getMessages($conversation, $perPage = 25);
```

### Listing Conversations

[](#listing-conversations)

To list the conversations a user is involved in:

```
$conversations = $user->conversations;
```

### Authorization and Validation

[](#authorization-and-validation)

Authorization checks are made during conversation and message operations using policies. For example, to check if a user has access to a conversation:

```
$this->authorize('view', $conversation);
```

### Real-Time Communication

[](#real-time-communication)

For real-time communication, you can use Laravel Echo and Pusher (or your WebSocket provider of choice).

### Laravel Echo Setup

[](#laravel-echo-setup)

Configure Laravel Echo in your `resources/js/bootstrap.js` file:

```
import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    encrypted: true,
});
```

### Listening to Events

[](#listening-to-events)

For example, in a Vue.js component:

```
mounted() {
    Echo.join(`conversation.${this.conversationId}`)
        .here((users) => {
            this.participants = users;
        })
        .joining((user) => {
            this.participants.push(user);
        })
        .leaving((user) => {
            this.participants = this.participants.filter(u => u.id !== user.id);
        })
        .listen('MessageSent', (e) => {
            this.messages.push(e.message);
        });
},
```

### Testing

[](#testing)

Tests have been written to ensure the reliability of your package. To run the tests:

```
vendor/bin/phpunit
```

Customization
-------------

[](#customization)

### Configuration

[](#configuration)

You can customize the package settings in the `config/chat.php` file.

- user\_model: The user model to be used in the messaging system.
- broadcast\_driver: The broadcast driver to be used (e.g., pusher, ably).

### Views

[](#views)

To publish and customize the view files:

```
php artisan vendor:publish --provider="TolgaTasci\Chat\Providers\ChatServiceProvider" --tag="views"
```

### Security

[](#security)

- Authorization: Ensures users can only access the conversations and messages they are authorized for through policies.
- Input Validation: User inputs are validated using Form Request classes.
- XSS and CSRF Protection: Laravel's default protections are used.

Contributing
------------

[](#contributing)

We welcome contributions. To contribute, please follow these steps:

- Fork this project.
- Create a new branch: git checkout -b my-new-feature.
- Make your changes and commit them: git commit -am 'Add some feature'.
- Push to your branch: git push origin my-new-feature.
- Open a Pull Request.

License
-------

[](#license)

This project is licensed under the MIT License. For more information, see the [LICENSE](LICENSE) file.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6950576eb6089770dc25c152c0a627108d5ec2625a737b40a0e9691789096441?d=identicon)[tolgatasci](/maintainers/tolgatasci)

---

Top Contributors

[![tolgatasci](https://avatars.githubusercontent.com/u/9893685?v=4)](https://github.com/tolgatasci "tolgatasci (13 commits)")

---

Tags

chatlaravellaravel-chatlaravel-chat-packagereal-timerealtime-chat

### Embed Badge

![Health badge](/badges/tolgatasci-chat/health.svg)

```
[![Health](https://phpackages.com/badges/tolgatasci-chat/health.svg)](https://phpackages.com/packages/tolgatasci-chat)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
