You are here: Foswiki>PM Web>WebPreferences>WebLeftBar>PerlStuff>CatalystFirstBlood (03 Nov 2006, SteffenSchwigon?)EditAttach
catalyst_logo3.png

Einstiegs-Kram rund um Catalyst

 

Homepage und Links

First Blood - Notizen beim ersten Ausprobieren

Installieren via CPAN-Shell

  • install Catalyst

Weitere Module:

  • install Catalyst::Engine::FastCGI
  • install Test::WWW::Mechanize::Catalyst
  • install Catalyst::View::Mason (vorher(!!) apt-get install libhtml-mason-perl)
  • install Catalyst::Model::DBIC
  • install Catalyst::Model::DBIC::Schema

Session-Handling:

  • Catalyst::Plugin::Session
  • Catalyst::Plugin::Session::State::Cookie
  • Catalyst::Plugin::Session::Store::File

Sonstiges:

  • Catalyst::Plugin::Email
  • Catalyst::Plugin::Unicode

Mit FASTCGI:

  • install FCGI
  • install FCGI::ProcManager

Mit Apache:

  • install Catalyst::Engine::Apache

Mit Template::Toolkit:

  • install Catalyst::View::TT

Mit Class::DBI:

  • install Catalyst::Model::CDBI
  • install Class::DBI::SQLite

Scaffolding:

  • install Catalyst::Helper::Controller::Scaffold
  • install Catalyst::Helper::Controller::Scaffold::Mason

Authentication:

  • Catalyst::Plugin::Authentication
  • Catalyst::Plugin::Authorization::Roles
  • install Catalyst::Plugin::Authentication::Store::DBIC

Applikationsrahmen bauen

$ catalyst.pl My::First::Cat::App
$ cd My-First-Cat-App/
$ script/my_first_cat_app_server.pl
  ... logs ...
  nebenher Browser auf http://localhost:3000/ zeigen
  mit Ctrl-C abbrechen

Testframework benutzen

$ perl Makefile.PL
$ make
$ make test

erstes Model

script/my_first_cat_app_create.pl model OpenGeoDB DBIC dbi:SQLite2:/home/ss5/local/projects/geo-opengeodb-data/lib/Geo/OpenGeoDB/Data/opengeodb.sqlite

erste View

script/my_first_cat_app_create.pl view OpenGeoDB TT

erster Controller

script/my_first_cat_app_create.pl controller OpenGeoDB

Catalyst Deployment

Standalone

script/my_first_cat_app_server.pl -r

Apache

FastCGI (empfohlen von Peter Schlönzke)

apt-get install libapache-mod-fastcgi
cpan FCGI::ProcManager

Apache-Config (außerhalb von VirtualHost)

  FastCgiServer   /home/ss5/projects/myapp/catalyst/script/my_first_cat_app_fastcgi.pl -processes 3
  Alias /myapp/   /home/ss5/projects/myapp/catalyst/script/my_first_cat_app_fastcgi.pl/

mod_perl

Einfach die Hauptapplikationsklasse (die im @INC liegen muss) als PerlHandler verwenden:

  <LocationMatch ^/myapp/>
    SetHandler           perl-script
    PerlHandler          My::First::Cat::App
  </LocationMatch>

Wenn man wie oben ein LocationMatch? mit Regex statt einer Location verwendet, schneidet Catalyst den basepath nicht weg. Das möchte man manchmal, z.B., wenn man den Anfang der URL mit einer Nicht-Catalyst-Anwendung teilen muss.

Mit anderen Worten: das Beispiel ist bereits ein Trick. Für den Durchschnittsgebrauch reicht ein <Location /myapp/> ... </Location>

Fallstricke

Fehlermeldung 'Use of "require" without parentheses is ambiguous'

Das passiert z.B., wenn eine Backup-Datei vom Editor nach einem Crash im Controller-Verzeichnis übrigbleibt, die wegen ihrer Endung .pm als Klasse zu laden versucht wird, aber natürlich kaputt ist.

-- SteffenSchwigon? - 22 Oct 2006

Topic revision: r3 - 03 Nov 2006 - 21:12:24 - SteffenSchwigon?
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback