Difference between revisions of "Catalyst"

From HalfgeekKB
Jump to navigation Jump to search
(Created page with "Notes on '''Catalyst''', an MVC web framework for perl. ==Installation== ===Other people's instructions=== * [http://wiki.dreamhost.com/Catalyst Getting this to work o...")
 
Line 44: Line 44:
 
ln -s /home/someuser/perl5/perlbrew/perls/myperl/bin/catalyst.pl ~/bin/myperl-catalyst.pl
 
ln -s /home/someuser/perl5/perlbrew/perls/myperl/bin/catalyst.pl ~/bin/myperl-catalyst.pl
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
====Test on a site====
 +
 +
Here, <code>sub.example.com</code> is a domain that has been set up with FastCGI enabled.
 +
 +
<syntaxhighlight lang=bash>
 +
perlbrew use myperl
 +
cd ~/sub.example.com
 +
catalyst.pl Test
 +
# Lots of files are created
 +
cd Test
 +
# This part corrects all the "/usr/bin/env perl" shebangs with the perlbrew perl
 +
find -type f -exec perl -p -i -e 's!/usr/bin/env perl!/home/someuser/perl5/perlbrew/perls/myperl/bin/perl!g' {} \;
 +
# "make sure your install is complete"
 +
perl Makefile.PL
 +
</syntaxhighlight>
 +
 +
After this, visiting the page
 +
 +
<nowiki>http://sub.example.com/Test/script/test_cgi.pl</nowiki>
 +
 +
results in a simple "Page not found" message. (If the result is a 500, something wasn't set up correctly.)

Revision as of 10:12, 14 January 2015

Notes on Catalyst, an MVC web framework for perl.


Installation

Other people's instructions

On Dreamhost with perlbrew

Here, I am using perlbrew instead of the typical instructions, and hope to bypass the whole local::lib thing.

Presume that myperl is a perlbrew environment that's already been set up and that its executable is at

/home/someuser/perl5/perlbrew/perls/myperl/bin/perl

Install modules with cpanm:

perlbrew use myperl
cpanm Catalyst::Runtime Catalyst::Devel

Version check

Run the following, which always fails:

perl -M"Catalyst 999"

If the failure is about a version number, the install worked (and the error displays the version number). Otherwise, there was a problem.

Link catalyst.pl

Instructions and tutorials refer to the bootstrap script catalyst.pl. This is installed in the bin dir of the perlbrew environment:

/home/someuser/perl5/perlbrew/perls/myperl/bin/catalyst.pl

To make this less of a mouthful, make this accessible from your path. In this example, I'll qualify it with the name of the perlbrew env in case I want to set this up for multiple sites; anytime the doc says "catalyst.pl" I'll substitute "myperl-catalyst.pl".

ln -s /home/someuser/perl5/perlbrew/perls/myperl/bin/catalyst.pl ~/bin/myperl-catalyst.pl

Test on a site

Here, sub.example.com is a domain that has been set up with FastCGI enabled.

perlbrew use myperl
cd ~/sub.example.com
catalyst.pl Test
# Lots of files are created
cd Test
# This part corrects all the "/usr/bin/env perl" shebangs with the perlbrew perl
find -type f -exec perl -p -i -e 's!/usr/bin/env perl!/home/someuser/perl5/perlbrew/perls/myperl/bin/perl!g' {} \;
# "make sure your install is complete"
perl Makefile.PL

After this, visiting the page

http://sub.example.com/Test/script/test_cgi.pl

results in a simple "Page not found" message. (If the result is a 500, something wasn't set up correctly.)