Awesome Open Source
Awesome Open Source


phpPM is a lightweight private messaging library

phpPM based on threads. Each new message starts a thread in which the conversation(between two user) runs ;)


  • Uses PDO
  • Uses prepare statements -> SQL-Injection safe
  • Each user has a MessageBox
  • Delete messages(not physically)
    • Delete the thread too if the thread has no messages
  • Delete threads(not physically)
  • Provide all needed functions for a postbox...

How to use

After you have configure phpPM(see you can use it as follow.

Get the MessageBox for your user:
$userId is just the unique id for the user in your application
$pdo here you can provide your database pdo object. You can also provide null to force phpPM to use your configuration
$msgBox = new MSGBox($userId,$pdo);

Let's send a new message to another user:
Now you have startet a conversation to answer just add(not send) a message to this thread:

Let's have a look at the thread:
$id we assume the thread is 100
$thread = $msgBox->getThread($id);
This function returns a 'Thread' object:
$messages = $thread->getMessages();
Now we have an array of 'MSG' that belongs to the thread
$messages[0]->getText(); // this provide the content of the message

They are more functions available that helps:
We can ask the thread if there new messages
$thread->hasNewMessages(); //true or false
$msgBox->getCountNotReadedMessages(); // count how much messages the user doesn't have readed now
$msgBox->getCountReadedMessages(); // count how much messages the user have readed now

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Php (287,418
User (47,161
Thread (12,446
Messaging (5,758
Pdo (1,795
Messaging Library (43