Download the PHP package vziks/chat-bundle without Composer
On this page you can find all versions of the php package vziks/chat-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vziks/chat-bundle
More information about vziks/chat-bundle
Files in vziks/chat-bundle
Package chat-bundle
Short Description Hush ChatBundle
License
Homepage https://github.com/Vziks/ChatBundle
Informations about the package chat-bundle
Hush ChatBundle
ChatBundle расширяет функционал symfony, добавляя возможность пользователям обмениваться сообщениями.
Зависимости:
- FosUserBundle
- Sonata Media Bundle
- NelmioApiDocBundle (Опционально для просмотра API документации)
Возможности:
- ChatService реализует сервис - функции для обмена сообщениями. В том числе добавлять медиафайлы (картинки) к сообщениям.
- Rest API для доступа к чат-функциям.
Установка
Предполагается что FosUserBundle и Sonata Media Bundle уже установлены.
Добавляем бандл через composer:
Регистрируем бандл в приложение:
Настраиваем config.yml:
Вместо AppBundle\Entity\User необходимо указать ваш конкретный класс, расширяющий базовую модель FOSUserBundle. Это тот же класс, который указан в конфиге как fos_user.user_class.
После этого необходимо расширить структуру БД командой:
Настройка
Необходимо настроить дополнительный контекст для Media Bundle для сохранения изображений в сообщениях. config.yml
Для контекста message можно настроить несколько форматов, в примере настроено 2: small и big. После этого необходимо зафиксировать новый контекст в БД:
Использование
Возможно 2 варианта использования бандла:
- Прямое использование функций чат-сервиса
- Использование Rest API бандла
Использование функций чат - сервиса
Регистрируем сервис в services.yml
Использование:
Список методов и их описание смотрите в классе сервиса Hush\ChatBundle\Service\ChatService
Использование Rest API
Регистрируем контроллер в routing.yml:
Закрываем доступ неавторизованным пользователям в security.yml:
Также необходимо реализовать метод аутентификации пользователя. Например по определённому apikey пользователя. Для просмотра документации Chat Bundle Rest API необходимо установить и настроить NelmioApiDocBundle.
Кастомизация сериализации сообщений
При необходимости можно использовать свой способ сераилизации сообщений. Для этого необходимо реализовать свой сервис, реализующий интерфейс \Hush\ChatBundle\Service\MessageSerializerInterface Например:
Зарегистрировать его в services.yml
И указать его в config.yml