
Install a local web server with XAMPP to develop a PHP chat application, enabling MySQL and Apache on your computer. Download XAMPP from Apache Friends and start MySQL and Apache.
Create a real-time fb-messenger project by organizing folders under xampp htdocs, including core, ajax, classes, assets, content, and js, then test with localhost to print hello world.
Discover how composer, a PHP dependency manager, installs and manages libraries and their dependencies with a single command, enabling easy use of libraries like the Facebook SDK.
Install composer on Linux or MacOS by installing php-cli, downloading composer, verifying the installer, running php composer-setup.php, and wiring composer globally for convenient use.
Understand how web sockets enable full duplex, bi-directional real-time communication between browser and server using tcp/ip. Contrast full duplex with half duplex and see its use in real-time chat.
Install the ratchet php library with composer to enable a websocket server for real-time browser-to-server chat. Prepare the autoloader and begin building the fb messenger chat logic for later integration.
Create a database for the real-time chat application using phpMyAdmin, accessed via localhost/phpMyAdmin, and name it fb-messenger to store users messages.
Create a login form and login page for the real-time messenger app, guiding users through validating emails and passwords and preparing the main page access.
Create a users table in the messenger database with seven columns, including user_id as primary key and auto increment, plus username, email, password, profile_image, session_id, and connection_id.
Validate the login form with php by handling post requests, sanitizing inputs (trim, stripslashes, htmlspecialchars), and validating the email format, while displaying errors for empty or invalid fields.
Create a reusable PHP database connection class to centralize MySQL access, define host, database, and credentials, and include it in scripts to execute queries like select * from users.
Create a PHP method to check if an email exists in the database using a prepared statement and bound parameter, including class construction and database connection steps.
Create a password hash method using PHP to hash and verify user passwords with the default Blowfish-based password_hash and password_verify, enabling secure login against stored credentials.
Create a redirect method in the user class to route to a specific page, then implement login logic that starts a user session and redirects to the home page.
Create a public isLoggedIn function in the user class that returns true if a session ID is set, and use a getId method to obtain the user ID for homepage.
Create a public log out function that clears the user session and redirects to the index page, with testing on the home page.
Develop a reusable PHP method to fetch user data by user id or the logged-in user using prepared statements, binding parameters, and secure access to the users table.
Build a reusable php method to select fields from any table, construct the where clause, bind values for each field, execute the prepared statement, and return user data.
Create a reusable PHP function to insert data into a database by preparing and binding an insert statement with columns and values, and returning the last inserted id.
Create the home page for the real-time chat messenger by integrating the home file, linking the logo, adding logout, and enabling real-time message display and user search.
Create a messages table for a real-time chat app using PHP and MySQL, defining eight columns such as message_id, message, sender_id, recipient_id, created_at, and type (message or image).
Develop a search box in a real-time chat app by wiring a keyup event, retrieving input, sending AJAX to a PHP script, and toggling between recent messages and search results.
Create a search method in the user class to query the database for users using a bound parameter and a wildcard like search, then display results.
Create a method in the messenger class to display recent messages by joining messages with user data, using the current user id, and securing the database query.
Learn to display each user's latest message by grouping messages by user id, selecting the max message id, and joining with the users table to show recent chats.
Build a redirect method in the messenger class to go to the last message using a left join and order by message id, then direct to the user’s messages page.
Enable the Apache rewrite engine and create rules to route messenger requests, extract the username from the URL, and display real-time chat messages with PHP.
Display the real messenger interface and chat messages. Implement the user data method, base URL, profile image, and recent messages for the main messenger page with JavaScript search.
Create a public function to fetch user data by username, returning the user object and validating lock status; read the username from the url and redirect home if not found.
Create a method to fetch and display latest chat messages by joining messages and users, binding sender id, and displaying messages on the right or left.
Display a not seen icon for unread messages with a condition and format time via a date time object to show hours and minutes with am/pm, and show image tags.
Create a JavaScript function to validate a selected image from a file input and upload it to a chat recipient via a server endpoint.
develop a PHP image upload method for a real-time messenger, validating file type and size, extracting file info and extension, and storing the uploaded image on the server.
Learn to upload a user image by posting image and user data, validate and save the file, and return a JSON response with the upload status and image URL.
Display uploaded images in the chat by converting a JSON string to a JavaScript object, appending image messages to the chat panel, and testing image posting in the interface.
Create a send message method that stores messages in the messages table with sender, receiver, type, time, and image data, then display the image in the chat.
Fix recent messages by updating the messenger class to display images correctly, show the tick badge properly, and render image tags conditionally based on sender using a user id check.
Develop a dynamic update method in PHP to modify messenger messages in a MySQL table, handling fields, conditions, and binding values to update status, time, and content.
Create a method to mark messages as seen when the recipient views them. Integrate the method with the messenger class to update the messages table via the user update method.
Enable the chat textarea to send messages, integrate an emoji picker, capture the enter key, post messages, clear the input, and update the messages display.
Set up a PHP WebSocket server by loading the chat class with composer autoload, defining the namespace, and launching the server to test a browser connection.
Build and manage session tokens in a real-time chat app to identify connected users via browser and server, updating sessions on login and retrieving users by session ID.
Learn how the chat class uses ratchet components to establish a web socket connection between client and server, handling open, message, close, and error events and broadcasting to connected clients.
Learn to instantiate class objects for a chat module by configuring the namespace, referencing the user and messenger classes, and wiring public user and message variables to ready the setup.
Implement token based verification for websocket connections by extracting a token from the URL, validating it against user data, and updating the connection record with the user id and username.
Create a method to send and store messages via web socket, decode json data, identify sender and receiver, insert into the messages table, and attach user data for display.
Display real-time chat messages using WebSocket, showing sender and receiver messages, handling text and image messages, and updating the chat UI with user data.
Display a new incoming message on the left side by updating the recent messages list with the sender's username, profile image, and a 12-hour time for real-time chat.
Add a conditional flow to the recent messages: check the user id, update an existing message or insert a new one, update display time and badge in the messenger class.
Create a scroll down method for the real-time chat messenger using websockets, php, and mysql that auto-scrolls as new messages arrive.
Fix the duplicate image message bug in a real-time chat built with websockets, PHP, and MySQL by inspecting and adjusting the image handling logic.
Wanted to build your own REAL TIME chat just like Facebook Messenger? and don't know where to start from? Don’t worry, this Course will show you step by step how to create your own Facebook Messenger clone using WebSockets. Yes, we will be using websockets in PHP along with MySQL, Javascript.
It doesn't matter if you're a beginner or an experienced programmer, just you have to know the basics of PHP, MySQL, HTML ,CSS and JQuery.
This course will be greatly and highly beneficial to you. And by the end of this course you will be capable of creating your own Real Time Chat Just like Facebook, not only this you will also be more than competent with skills WebSockets, Ratchet, PHP, PDO, OOP, MySQL and jQuery.
You can highlight the site you create in this course, If anyone who sees this project in your portfolio might want to hire you because from this course you will gain skills which help you to understand the main concept used in the Real Time Communication system. So get the ULTIMATE guide to create a REAL TIME Chat Application Like Facebook Using Websockets and PHP.
Support
By taking this course you will get my full support. I've always loved to help my students (could be you). I’ve answered all that question that students have asked so far. I’m always in a ninja mood, if there’s a question it’ll be answered within an hour or few. By all this means if you have any errors. I'll be happy to check codes, errors.
This Course Covers The Following Features:
One to one chat
WebSocket Server
Ratchet
Clients Connections Logic
Store Messages Logic
Display messages in real time
Emojis
Post Message
Post Image
Tokens
Sessions
Please
look at all the lectures to see more things that are covered.