Catalystの練習 - 1行伝言板を再実装してみる
スケルトンの生成
>perl C:\Perl\site\bin\catalyst.pl msgboard
created "msgboard\script"
created "msgboard\lib"
created "msgboard\root"
created "msgboard\root\static"
created "msgboard\root\static\images"
created "msgboard\t"
created "msgboard\lib\msgboard"
created "msgboard\lib\msgboard\Model"
created "msgboard\lib\msgboard\View"
created "msgboard\lib\msgboard\Controller"
created "msgboard\msgboard.yml"
created "msgboard\lib\msgboard.pm"
created "msgboard\lib\msgboard\Controller\Root.pm"
created "msgboard/README"
created "msgboard/Changes"
created "msgboard\t/01app.t"
created "msgboard\t/02pod.t"
created "msgboard\t/03podcoverage.t"
created "msgboard\root\static\images\catalyst_logo.png"
created "msgboard\root\static\images\btn_120x50_built.png"
created "msgboard\root\static\images\btn_120x50_built_shadow.png"
created "msgboard\root\static\images\btn_120x50_powered.png"
created "msgboard\root\static\images\btn_120x50_powered_shadow.png"
created "msgboard\root\static\images\btn_88x31_built.png"
created "msgboard\root\static\images\btn_88x31_built_shadow.png"
created "msgboard\root\static\images\btn_88x31_powered.png"
created "msgboard\root\static\images\btn_88x31_powered_shadow.png"
created "msgboard\root\favicon.ico"
created "msgboard/Makefile.PL"
created "msgboard\script/msgboard_cgi.pl"
created "msgboard\script/msgboard_fastcgi.pl"
created "msgboard\script/msgboard_server.pl"
created "msgboard\script/msgboard_test.pl"
created "msgboard\script/msgboard_create.pl"
データベースの作成
MySQL Query Browser
MySQL Administrator
MySQL Query Browser で Create New Schema "msgboard"
Schema "msgboard" に Create New Table "access"
Viewの生成
>cd msgboard
>perl .\script\msgboard_create.pl view TT TT
created "lib\msgboard\View"
created "t"
created "lib\msgboard\View\TT.pm"
created "t\view_TT.t"
Modelの生成
>perl .\script\msgboard_create.pl model CDBI CDBI DBI:mysql:msgboard **USER** **PASS**
created "lib\msgboard\Model"
exists "t"
created "Model\CDBI.pm"
created "Model\CDBI"
created "Model\CDBI\Access.pm"
created "Model\CDBI\Message.pm"
exists "t"
created "t\model_CDBI-Access.t"
exists "t"
created "t\model_CDBI-Message.t"
とりあえずこれでスケルトンできたので、ちょっと味見
>perl .\script\msgboard_server.pl -r
[debug] Debug messages enabled
[debug] Loaded plugins:
.----------------------------------------------------------------------------.
Catalyst::Plugin::ConfigLoader 0.13 Catalyst::Plugin::Static::Simple 0.15 '----------------------------------------------------------------------------'
[debug] Loaded dispatcher "Catalyst::Dispatcher"
[debug] Loaded engine "Catalyst::Engine::HTTP::Restarter"
[debug] Found home "msgboard"
[debug] Loaded Config "msgboard\msgboard.yml"
[debug] Loaded tables "access message"
[debug] Loaded components:
.-----------------------------------------------------------------+----------.
Class Type
- +
msgboard::Controller::Root instance msgboard::Model::CDBI instance msgboard::Model::CDBI::Access instance msgboard::Model::CDBI::Message instance msgboard::View::TT instance '-----------------------------------------------------------------+----------'
[debug] Loaded Private actions:
.----------------------+--------------------------------------+--------------.
Private Class Method
- +
/default msgboard::Controller::Root default /end msgboard::Controller::Root end '----------------------+--------------------------------------+--------------'
[info] msgboard powered by Catalyst 5.7006
You can connect to your server at http://localhost:3000