Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

ZendFrameworkでAjax版Chatを作るチュートリアル

英語のドキュメントですが、コードもダウンロードできます。英語はダメでも、コードは万国共通です :-)
コードを実際に動作させる場合は、

  • コードはDocumentRoot以下に配置する必要がある場合がある
    • mod_rewriteを使ってますが、PTフラグがないので、バージョンによっては必要です。まあ、PTフラグを付けても良いんですが。。。
  • コードを展開したディレクトリに対するAllowOverrideディレクティブにFileInfoとOptionsが含まれている必要がある
  • PHPの入出力・内部エンコーディングUTF-8にしないと、日本語が化ける
    • internal_encodingをUTF-8にして、http_outputをpass、encoding_translationをOffにするのが一番手っ取り早いかも。.htaccessで指定するなら、次のような感じ。まあ、必要に応じて。。。
php_value mbstring.internal_encoding utf-8
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation  Off
php_value output_handler none
    • チャットデータをUTF-8XMLファイルとしてdataディレクトリに出力。コードは見てませんが、入力値のエンコーディングを変換せずに出力してるっぽい?
    • ZendFrameworkでの規約ですかね?

に注意する必要があります。


Creating a chat application is not a difficult task. Honest!

This tutorial is a step by step introduction to creating a lightweight chat application using XML as a storage medium. As personal motivation, I develop PHP games as a hobby. In pursuit of that hobby I've found that offering a flat threadless forum in such games tends to result in heavy usage as players attempt to use it as a chat room. The reason is that even with the advent of irc and instant messengers, users continue see an alternative web based solution as attractive for a number of reasons whether its limited access to instant messengers through a corporate proxy or simply for convenience sake.