title: How to integrate a COMET chat in a PHP application
body: <p>I'm thinking of integrating a chat inside an already written and working php application.
  As I have to choose the chat implementation yet I'll show you some consideration:</p>
  
  <ol>
  <li>PHP is not good for Comet application. A php comet server for managing chat would not scale well, so it wouldn't be my first choice.</li>
  <li>Node.js + Socket I/O, can eventually be a good option for the chat engine.</li>
  <li>AMQP (RabbitMQ?) can be another possibly good solution, not exclusive with node.js as they can integrate pretty well.</li>
  </ol>
  
  <p>The main problem is: how can I avoid code and business  logic duplication? There are some aspects I'd like to point out:</p>
  
  <ul>
  <li>The application manages users in a RBAC fashion. Users should be able to chat with other users depending on their role (and some other business logics). It would be hard (and bad practice imo) to duplicate that logic.</li>
  <li>If I use two different server processes (as I think) for IM and application, how can I manage http session?</li>
  </ul>
  
  <p>In short: IM would be tightly coupled with business logic, so I really need to avoid code/logic duplication, but at the same time I don't want a PHP chat engine.</p>
  
  <p>Thank you in advance.</p>