zakharov-andrew/yii2-messenger

Yii2 Messenger

v0.0.1 2025-03-28 21:40 UTC

This package is auto-updated.

Last update: 2025-04-01 23:40:09 UTC


README

πŸš€ Yii2 messenger - Chat Module for Yii2 πŸ“¨βœ¨

Latest Stable Version Total Downloads License Yii2

The Yii2 messenger provides a complete solution for messaging between users, including private conversations and group chats with advanced management capabilities.

Features β€’ Installation β€’ Usage β€’ System Requirements β€’ Contributing β€’ License

πŸ‡·πŸ‡Ί Русская вСрсия

πŸ”₯ Features

πŸ’¬ Messaging System

  • Real-time text messaging ⚑
  • Message history view πŸ“œ
  • Delete your own messages πŸ—‘οΈ
  • Admin ability to delete any messages πŸ›‘οΈ

πŸ‘₯ Group Chats

  • Create chats with name and description 🏷️
  • Upload chat avatar πŸ–ΌοΈ
  • Different access types:
    • πŸ”— Public (via link)
    • βœ‰οΈ Invite-only
    • πŸ”’ Private (manual addition only)
  • View participant list πŸ‘€

πŸ›  Chat Management (for admins)

  • Assign administrators πŸ‘‘
  • Flexible permission system:
    • Delete messages πŸ—‘οΈ
    • Ban users β›”
    • Temporary mute users πŸ”•
    • Add/remove participants βž•βž–
    • Edit chat info ✏️
    • Manage other admins πŸ›‘οΈ
  • View statistics and activity πŸ“Š

🀝 Private Messages

  • Automatic chat creation for first message πŸ€–
  • List of all conversations πŸ“‹
  • Search message history πŸ”

πŸš€ Installation

The preferred way to install this extension is through composer.

Either run

$ composer require zakharov-andrew/yii2-messenger

or add

"zakharov-andrew/yii2-messenger": "*"

to the require section of your composer.json file.

Subsequently, run

./yii migrate/up --migrationPath=@vendor/zakharov-andrew/yii2-messenger/migrations

in order to create the settings table in your database.

Or add to console config

return [
    // ...
    'controllerMap' => [
        // ...
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationPath' => [
                '@console/migrations', // Default migration folder
                '@vendor/zakharov-andrew/yii2-messenger/src/migrations'
            ]
        ]
        // ...
    ]
    // ...
];

Usage

Add this to your main configuration's modules array

    'modules' => [
        'messenger' => [
            'class' => 'ZakharovAndrew\messenger\Module',
            'bootstrapVersion' => 5, // if use bootstrap 5
            'defaultChatImage' => '/images/default-product-image.jpg', // Path to the default image for a chat
            'uploadWebDir' => '/web/path/to/upload/dir/'
        ],
        'imageupload' => [
            'class' => 'ZakharovAndrew\imageupload\Module',
            'uploadDir' => '/path/to/upload/dir/',
        ],
        // ...
    ],

Note: the maximum number of additional parameters is 3. Change the value of uploadDir to the directory for uploading images. Uses the yii2-image-upload-widget module to upload images.

Add this to your main configuration's urlManager array

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                // ...
                'chat/<url:[\w\d\-]+>' => 'messenger/chat/view',
                // ...
            ],
        ],

🎨 Frontend Integration

The module provides:

  • Ready-to-use AJAX controllers for easy integration πŸ“‘
  • Responsive interface (mobile-friendly) πŸ“±
  • Customizable styling options 🎨

πŸ“Œ System Requirements

  • PHP 7.4+
  • Yii2 2.0.40+
  • MySQL 5.7+ or PostgreSQL 9.5+

πŸ‘₯ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.