iFlyChat
  • Documentation
  • Installation
    • WordPress Chat Plugin
    • Drupal Chat Module
    • PHP Chat Client
  • WordPress
    • Embed Chatroom in WordPress Post
    • Disable Popup Chat
    • Hide Popup Chat from a Page
    • Embed Inbox View
    • View Chat Logs
    • Guest User Access
    • Show/Hide Popup Chat On Specific Pages
    • WordPress Filters and Hooks
  • API Reference
    • Create a new chat room
    • Retrieve list of all chat rooms
    • Edit a chat room
    • Retrieve list of all online users
    • Kick a user from the chat
    • Retrieve list of all users online in a chat room
    • Delete a chat room
    • Retrieve Thread History
  • JavaScript SDK
    • Quickstart
    • Custom Label In Chat Window
    • User Chat Button Widget
    • Reference
      • message receive
      • message send
      • user list update
      • connect
      • disconnect
      • ready
      • iflychat.startChat
      • iflychat.closeChat
      • iflychat.minimiseChat
      • iflychat.init
      • iflychat.setStatus
      • iflychat.sound
      • iflychat.openAdminDashboard
      • current user status update
      • current user sound update
      • iflychat.renderLabelInChatWindow
  • Help
    • General
      • Introduction
      • Accounts and Billing
      • Chat Theme and Colors
      • Chat Notification Sound
      • Going Offline
      • Change billing card information
    • Embedded Chatroom
      • Create a New Room
      • Create a New Embed Room
      • Embed Room in PHP
    • Feature Description
      • Moderated Chatroom
      • Group Chat
      • Private Embedded Chatroom
      • Change Guest Name
      • Resize Popup Chat Window
      • Mute Sound Notification
      • Change User Status
      • Desktop Notification
      • Popout or Full Screen Mode
      • Share Media Files
      • Video Chat
    • Chat Moderation
      • Kick/Ban/BanIP
      • Delete or Clear Messages
      • Popup Chat Position
      • Popup Chat Launcher Position
      • App Dashboard
      • Emoji Packs
      • Message Display Format
      • Time Display Format
      • Mobile Web Chat
      • Show Only Admins in Chat
      • Hide Recent Chats Section
      • Hide Users in Popup Chat List
      • Hide Popup Chat List
      • Minimize Popup Chat List
Powered by GitBook
On this page

Was this helpful?

  1. Installation

PHP Chat Client

Learn how to integrate our chat into your PHP website

PreviousDrupal Chat ModuleNextEmbed Chatroom in WordPress Post

Last updated 5 years ago

Was this helpful?

How to integrate iFlyChat with any PHP based website

Step 1: You can get the iFlyChat PHP library via a composer package called iflychat-php. See .

$ composer require iflylabs/iflychat-php

Or add to composer.json:

"require": {
    iflylabs/iflychat-php": "^2.0"
}

and then run composer update.

Or you can clone or download the library files.

We recommend you to .

Step 2: Generate APP ID and API Key from and copy them.

Step 3: Use these credentials in your main php(index) file to create a new iFlyChat instance.


use Iflylabs\iFlyChat;

const APP_ID = 'YOUR_APP_ID';
const API_KEY = 'YOUR_API_KEY';

$iflychat = new iFlyChat(APP_ID, API_KEY);

Step 4(optional): In case, you want to create a user for the chat, you just need to call the setUser() function with $user array as a parameter.

Example.

$user = array(
  'user_name' => 'testUser', // string(required)
  'user_id' => '2', // string (required)
  'is_admin' => FALSE, // boolean (optional)
  'user_avatar_url' => 'user-avatar-link', // string (optional)
  'user_profile_url' => 'user-profile-link', // string (optional)
);

$iflychat->setUser($user);

Step 5: Now, you need to include iFlyChat HTML code in your website. As an example, check out basic-example.php (inside iflychat-php/examples folder). To do so, add the following line of code before printing anything on the webpage:

$iflychat_code = $iflychat->getHtmlCode();

Step 6: Make sure to use the above code before printing any content via PHP, otherwise you will get an error. Next, use the following code anywhere in your PHP file (preferably before body tag ends) to render the chat:

<html>
<head>
</head>
<body>
<h1>How to include iFlyChat in your PHP website?</h1>

<!-- iFlyChat Engine Code Begins -->
<?php print $iflychat_code; ?>
<!-- iFlyChat Engine Code Ends -->

</body>
</html>
https://packagist.org/packages/iflylabs/iflychat-php
use composer
iflychat.com