Playframeworkのデモを試してみるその2 - Tasks アプリ作成+Eclipse

順調にのんびり進める
デモでは Tasks ってアプリケーションを作成していく

Tasksアプリケーションを実行する

Tasksアプリケーションの雛型を作成する

コマンドラインプロンプトで


> cd c:/eclipse/workspace/
C:\eclipse\workspace>play run tasks
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.0.1, http://www.playframework.org
~
~ The new application will be created in C:\eclipse\workspace\tasks
~ What is the application name? Tasks
~
~ OK, the application is created.
~ Start it with : play run tasks
~ Have fun!
~

C:\eclipse\workspace>

What is the application name? のところで入力要求、 Tasks と入力して続けるとおしまい。

ディレクトリ構成
実行する

コマンドラインプロンプト、カレントディレクトリを c:/eclipse/workspace/ に移して


C:\eclipse\workspace>play run tasks
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.0.1, http://www.playframework.org
~
~ Ctrl+C to stop
~
Listening for transport dt_socket at address: 8000
19:52:42,946 INFO ~ Starting C:\eclipse\workspace\tasks
19:52:43,837 WARN ~ You're running Play! in DEV mode
19:52:44,102 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
以上が表示されて止まる。
そのままブラウザで、 http://localhost:9000/ にアクセスすると
Your application is ready ! といったタイトルのWebが表示される
と、同時に実行されっぱなしのコマンドラインプロンプトは

19:54:08,543 INFO ~ Application 'Tasks' is now started !
と、1行追加されているはず。
確認できたら、コマンドラインプロンプトで Ctrl+C 押下で終了。

Eclipse のプロジェクトとして認識させる

※ここはデモムービーでは実施されていません

eclipsifyを実行

コマンドラインプロンプト、カレントディレクトリを c:/eclipse/workspace/ に移して


C:\eclipse\workspace>play eclipsify tasks
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.0.1, http://www.playframework.org
~
~ OK, the application is ready for eclipse
~ Use File/Import/General/Existing project to import C:\eclipse\workspace\tasks into eclipse
~
~ Use eclipsify again when you want to update eclipse configuration files.
~ However, it's often better to delete and re-import the project into your works
pace since eclipse keeps dirty caches...
~

C:\eclipse\workspace>

Eclipseにプロジェクトをインポート

Eclipse を起動して
メニューから File => Import...
=> Existing Projects into Workspace => Next
=> Select root directory: c:/eclipse/workspace/tasks/
=> Finish
Eclipse に tasks プロジェクトが登場する

Eclipseからサーバ起動

プロジェクトルートからディレクトリを降りて、
tasks/eclipse/Tasks.launch を右クリック
=> Run As => Tasks
で、良いはずなんだけどエラー発生

プロジェクト Tasks が見つからんとな?解せん。
と、いうわけでEclipseのプロジェクト名を tasks から Tasks に変更
再び実行すると、成功。

確認

ブラウザで http://localhost:9000/ を見てみると
そこにはさっき見た Your application is ready ! が・・・・出てこないこともある。
これはどうやら pleiades で導入すると Play で使用する 9000 番ポートが
PHP デバッガである XDebug とかぶるせいみたい。
今は Play がしたいので XDebug のポートを適当にずらす

XDebug のポートをずらす

Eclipse メニューから Window => Preferences
左のツリーをたどる => PHP => Debug => Installed Debuggers
右 => Installed Debuggers から XDebug を選択して Configure
=> Debug Port を適当に(自分はとりあえず 9001にした)

確認リトライ

先の手順をリトライ(Play を起動してからブラウザで http://localhost:9000/ )すると
Your application is ready !

ちょっと山あったが良い良い