Your SlideShare is downloading. ×
0
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Modern  Catalyst
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Modern Catalyst

4,203

Published on

0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,203
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
51
Comments
0
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Transcript

    • 1. modern Catalyst Hideo Kimura
    • 2. about me
    • 3. about me • hide-k
    • 4. about me • hide-k • hideki
    • 5. about me • hide-k • hideki • hide
    • 6. about me • hide-k • hideki • hide • DeNA
    • 7. about me • hide-k • hideki • hide • DeNA • MobaSif
    • 8. Catalyst
    • 9. Agenda
    • 10. Agenda • How to extend modern Catalyst on your applications
    • 11. Agenda • How to extend modern Catalyst on your applications • Not Catalyst introducing
    • 12. Agenda • How to extend modern Catalyst on your applications • Not Catalyst introducing • Not plugin recomendation
    • 13. Agenda • How to extend modern Catalyst on your applications • Not Catalyst introducing • Not plugin recomendation • Not tips
    • 14. Agenda • How to extend modern Catalyst on your applications • Not Catalyst introducing • Not plugin recomendation • Not tips • No
    • 15. Catalyst 5.8
    • 16. Catalyst 5.8 • 13 Oct 2008
    • 17. Catalyst 5.8 • 13 Oct 2008 • Deprecation
    • 18. Catalyst 5.8 • 13 Oct 2008 • Deprecation • Catamoose
    • 19. Deprecation
    • 20. Deprecation • ::[M V C]:: style
    • 21. Deprecation • ::[M V C]:: style • NEXT
    • 22. Deprecation • ::[M V C]:: style • NEXT • use MRO::Compat
    • 23. Deprecation • ::[M V C]:: style • NEXT • use MRO::Compat • __PACKAGE__->mk_accessors()
    • 24. Deprecation • ::[M V C]:: style • NEXT • use MRO::Compat • __PACKAGE__->mk_accessors() • use Moose attribute ‘has’
    • 25. Deprecation • ::[M V C]:: style • NEXT • use MRO::Compat • __PACKAGE__->mk_accessors() • use Moose attribute ‘has’ • and more...
    • 26. Moose
    • 27. Moose • A postmodern object system for Perl5
    • 28. Moose • A postmodern object system for Perl5 • Meta Object Protocol sugar syntax
    • 29. Moose • A postmodern object system for Perl5 • Meta Object Protocol sugar syntax • attributes
    • 30. Moose • A postmodern object system for Perl5 • Meta Object Protocol sugar syntax • attributes • method modifiers
    • 31. Moose • A postmodern object system for Perl5 • Meta Object Protocol sugar syntax • attributes • method modifiers • roles
    • 32. Application package MyApp; use strict; use warnings; use parent qw/Catalyst/; use Catalyst qw/ -Debug ConfigLoader Static::Simple/; __PACKAGE__->config( name => 'MyApp' ); __PACKAGE__->setup(); 1;
    • 33. Moose-ified Applicatoion package MyApp; use Moose; extends 'Catalyst'; __PACKAGE__->config(name => 'MyApp'); __PACKAGE__->setup( qw/ -Debug ConfigLoader Static::Simple/ ); 1;
    • 34. Extend Application
    • 35. Extend Application • Plugin?
    • 36. Extend Application • Plugin? • Application namespace
    • 37. Extend Application • Plugin? • Application namespace • Helper Method
    • 38. Extend Application • Plugin? • Application namespace • Helper Method • Role
    • 39. Extend Application • Plugin? • Application namespace • Helper Method • Role • base Controller
    • 40. Extend Applicatoion package MyApp; ... after finalize => sub { my $c = shift; $c->log->(‘finalize’); }; sub foo { my $c = shift; $c->log->debug(‘foo’); } 1;
    • 41. Extend Applicatoion package MyApp::Role::Foo; use Moose::Role; after finalize => sub { my $c = shift; $c->log->(‘finalize’); }; sub foo { my $c = shift; $c->log->debug(‘foo’); } 1;
    • 42. Extend Applicatoion package MyApp; ... __PACKAGE__->setup( qw/ -Debug ConfigLoader Static::Simple +MyApp::Role::Foo/ ); 1;
    • 43. Controller package MyApp::Contorller::Foo; use strict; use warnings; use parent ‘Catalyst::Controller’; sub foo : Path('foo') { my ($self, $c) = @_; $c->res->body('foo'); } 1;
    • 44. Moose-ified Controller package MyApp::Contorller::Foo; use Moose; BEGIN {extends ‘Catalyst::Controller}; sub foo : Path('foo') { my ($self, $c) = @_; $c->res->body('foo'); } 1;
    • 45. Extend Controller
    • 46. Extend Controller • Moose::Role
    • 47. Extend Controller • Moose::Role • MooseX::MethodAttributes
    • 48. Extend Controller • Moose::Role • MooseX::MethodAttributes • ActionClass
    • 49. Extend Controller • Moose::Role • MooseX::MethodAttributes • ActionClass • ActionRole
    • 50. Extend Controller package MyApp::Role; use Moose::Role -traits => 'MethodAttributes'; sub foo : Path('foo') { my ($self, $c) = @_; $c->log->debug('foo'); } 1;
    • 51. Extend Controller package MyApp::Controller::Foo; use Moose; BEGIN {extends ‘Catalyst::Controller’} with MyApp::Role; 1;
    • 52. ActionClass package MyApp::Action::Foo; use Moose; extends 'Catalyst::Action'; after execute => sub { my ($self, $controller, $c) = @_; $c->log->debug(‘foo’); }; 1;
    • 53. ActionClass ... sub foo : Path('foo') ActionClass('+MyApp::Action::Foo') { my ($self, $c) = @_; $c->res->body('foo'); } ...
    • 54. ActionClass ... sub _parse_Foo_attr { return ActionClass => ‘MyApp::Action::Foo’; } sub foo : Path('foo') Foo { ...
    • 55. ActionClass
    • 56. ActionClass • Pros
    • 57. ActionClass • Pros • Reusable
    • 58. Action Class
    • 59. Action Class sub foobar : Path(‘foobar’) ActionClass(‘Foo’) ActionClass(‘Bar’) {
    • 60. Action Class • Cons sub foobar : Path(‘foobar’) ActionClass(‘Foo’) ActionClass(‘Bar’) {
    • 61. Action Class • Cons sub foobar : Path(‘foobar’) ActionClass(‘Foo’) ActionClass(‘Bar’) {
    • 62. Action Class • Cons sub foobar : Path(‘foobar’) ActionClass(‘Foo’) ActionClass(‘Bar’) {
    • 63. Action Class • Cons sub foobar : Path(‘foobar’) ActionClass(‘Foo’) ActionClass(‘Bar’) { • NG
    • 64. Action Class • Cons sub foobar : Path(‘foobar’) ActionClass(‘Foo’) ActionClass(‘Bar’) { • NG • Sucks
    • 65. ActionRole
    • 66. ActionRole • Catalyst::Controller::ActionRole
    • 67. ActionRole • Catalyst::Controller::ActionRole • Moose::Role as Action
    • 68. ActionRole package MyApp::ActionRole::Foo; use Moose::Role; after execute => sub { my ($self, $controller, $c) = @_; $c->log->debug(‘foo’); }; 1;
    • 69. ActionRole package MyApp::Contorller::Foo; use Moose; BEGIN {extends ‘Catalyst::Controller::ActionRole’}; sub foo : Path('foo') Does('Foo') { my ($self, $c) = @_; $c->res->body('foo'); } ...
    • 70. ActionRole
    • 71. ActionRole sub foobar : Path(‘foobar’) Does(‘Foo’) Does(‘Bar’) {
    • 72. ActionRole • Pros sub foobar : Path(‘foobar’) Does(‘Foo’) Does(‘Bar’) {
    • 73. ActionRole • Pros sub foobar : Path(‘foobar’) Does(‘Foo’) Does(‘Bar’) {
    • 74. ActionRole • Pros sub foobar : Path(‘foobar’) Does(‘Foo’) Does(‘Bar’) {
    • 75. ActionRole • Pros sub foobar : Path(‘foobar’) Does(‘Foo’) Does(‘Bar’) { • OK
    • 76. Dispatcher • Path • Local • Global • Regex • LocalRegex
    • 77. Dispatcher • begin :Private • end :Private • auto :Private
    • 78. Dispatcher
    • 79. Dispatcher • default :Private
    • 80. Dispatcher • default :Private • default :Path
    • 81. Dispatcher • default :Private • default :Path • catchall :Path
    • 82. Dispatcher • default :Private • default :Path • catchall :Path • index :Private
    • 83. Dispatcher • default :Private • default :Path • catchall :Path • index :Private • index :Path :Args(0)
    • 84. Dispatcher • default :Private • default :Path • catchall :Path • index :Private • index :Path :Args(0) • home :Path :Args(0)
    • 85. Dispatcher
    • 86. Dispatcher • Chained
    • 87. Dispatcher • Chained • dispatch chains of actions
    • 88. Dispatcher package MyApp::Controller::Foo; use Moose; BEGIN {extends 'Catalyst::Controller'} sub root :Chained('/') PathPart('foo') CaptureArgs {} sub bar :Chained('root') PathPart Args(0) { #/foo/bar } sub baz :Chained('root') PathPart Args(1) { #/foo/baz/* } 1;
    • 89. Dispatcher • $c->forward • $c->detach • $c->go • $c->visit
    • 90. Model
    • 91. Model • Thin Contoroller, Smart Model
    • 92. Model • Thin Contoroller, Smart Model • Do not depend on Catalyst
    • 93. Model • Thin Contoroller, Smart Model • Do not depend on Catalyst • Model::Adaptor
    • 94. Model::Adaptor package MyApp::Model::Foo; use Moose; extends 'Catalyst::Model::Adaptor'; __PACKAGE__->config(     class       => 'MyApp::Foo' ); 1;
    • 95. Test • Catalyst::Test • Test::WWW::Mechanize::Catalyst
    • 96. Catalyst::Test use strict; use warnings; use Test::More; use HTTP::Request::Common; BEGIN { use_ok 'Catalyst::Test', 'MyApp' } my $req = GET('/'); my $res = request($req); #$res = get(‘/’) ok($res->is_success, 'index return ok'); is($res->content_type, 'text/html', 'content type is HTML'); like($res->content, qr/Home/, 'contains Home'); done_testing();
    • 97. Catalyst::Test ... my ($res, $c) = ctx_request('/'); ok($res->is_success, 'index return ok'); is($c->stash->{foo}, 'foo', 'statsh foo is foo'); ...
    • 98. Test::WWW::Mechanize::Catalyst use Test::WWW::Mechanize::Catalyst; my $mech = Test::WWW::Mecanize::Catalyst->new( catalyst_app => ‘MyApp’ ); $mech->get(‘/’); $mech->content_contains(‘Home’, ‘contains Home’); $mech->submit_form( form_number => 1, fields => { foo => ‘foo’, bar => ‘bar’ } ); $mech->content_contains(‘Foo’, ‘contains Foo’); ...
    • 99. Resources • Catalyst::Delta • Catalyst::Upgrading • Catalyst::Manual::ExtendingCatalyst • Catalyst::Manual::CatalystAndMoose • Catalyst::Manual::Cookbook • Perl • http://gihyo.jp/dev/serial/01/modern-perl • The Definitive Guide to Catalyst
    • 100. One more thing...
    • 101. PSGI
    • 102. PSGI
    • 103. PSGI • Perl Server Gateway Interface • just specification, not implementation • start developing at 2009/09/04 • talk in this morning • miyaga-san, tokuhirom-san
    • 104. Catalyst::Engine::PSGI MyApp Catalyst::Engine::PSGI Catalyst::Engine::* ::Impl::Coro ::Impl::Mojo
    • 105. Thank you

    ×