I am going to describe how I installed Catalyst, the surprisingly spicy web framework, written in perl. Since I use debian, and I prefer to develop on sid, this blog will refer to the installation of Catalyst on squeeze/sid. Squeeze is the Testing distribution of debian, one day it will become debian 6.0 when it grows up.
So what do we do? Well, its trivial really;
aptitude install libcatalyst-perl
This pulls in lots of dependencies, but that’s good. As Gabor says, code reuse is a good thing. So far the Catalyst Wiki has been useful, telling me there are debian binaries already packaged. But when I want to start up Catalyst and hack a bit, it kinda lets me down, pushing me to CPAN for a ‘Tutorial’. That’s cool, I’ll go check that out.
Well, I hop down a bit on the tutorial page, mostly because I already know the spiel about MVC, or Model, View, Control, and I don’t need to go through that again. It is useful to read if you are just starting out. The juicy bit I found is that there is a tool, appropriately called catalyst.pl (/usr/bin/catalyst.pl) which is our “helper” – this is the tool we’ll use to set up our Catalyst site.
Okay, it should be simple enough, I do this on the command line;
Thinking that I will get Catalyst to build my first project which I creatively named “first.” But no, I get this instead:
To use the Catalyst development tools including catalyst.pl and the
generated script/myapp_create.pl you need Catalyst::Helper, which is
part of the Catalyst-Devel distribution. Please install this via a
vendor package or by running one of -
perl -MCPAN -e 'install Catalyst::Devel'
perl -MCPANPLUS -e 'install Catalyst::Devel'
BEGIN failed--compilation aborted at /usr/bin/catalyst.pl line 24.
Well. That’s rude. It should just Do What I Mean! But it don’t, so more work for me. Fortunately there is an obscure but powerful tool in debian called apt-file which humbly describes itself as a tool to “search for files within Debian packages.” Because it does that, it can tell me which package holds the module I want. The above error message said I needed Catalyst::Devel, which is stored as a file called Catalyst/Devel.pm on a linux system, so I search like this;
apt-file search Catalyst/Devel.pm
apt-file conveniently tells me that Catalyst::Devel lives in libcatalyst-modules-perl. w00t! I install libcatalyst-modules-perl and it pulls in tons and tons of modules. No big deal really since this still only adds up to about 37 megs, which is a little big, but I can manage. A modular system is often preferable to a monolithic system, so I think we are alright here.
Now I run
catalyst.pl first and whaddya know? It works! Fantastic!
But how do I view my new masterpiece? Well, after further perusal of the documentation on CPAN, i.e. the tutorial, I can see that we are to
cd into the directory “first” which got created when I ran catalyst.pl. From there I run script/first_server.pl and viola, I get a bunch of Catalyst output. Now all I need to do is direct my browser to http://localhost:3000/ and I can see Catalyst serving dynamic web content. Yay! \o/