.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Gantry::Docs::QuickStart 3"
.TH Gantry::Docs::QuickStart 3 "2008-01-18" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "Name"
.IX Header "Name"
Gantry::Docs::QuickStart \- Getting your first Gantry app up and running
.SH "Off and running"
.IX Header "Off and running"
The easiest way to build a Gantry app with with bigtop:
.PP
.Vb 1
\& bigtop -n AppName 'book(title,pages:int4)<->author(name)'
.Ve
.PP
Choose a suitable application name and list the tables you've already
thought of, including their columns. When you think of more tables
and columns later, they will be easy to add. To learn more about
this kickstart syntax see Bigtop::ScriptHelp::Style::Kickstart.
.PP
If you have sqlite in your path, bigtop will build a database for you.
Then all you need to do is change to the directory it made for your app
and start the stand alone server.
.PP
.Vb 2
\& cd AppName
\& ./app.server
.Ve
.PP
If you don't use sqlite (or bigtop could not find it in your path), change
to the directory bigtop built for you. Create a database called app.db with
your database engine, populate the database, and start the app.server. With
Postgres that looks like this:
.PP
.Vb 4
\& cd AppName
\& createdb app.db -U postgres
\& psql app.db -U regular_user < docs/schema.postgres
\& ./app.server -d Pg -u regular_user -p password
.Ve
.PP
For MySQL, try this instead:
.PP
.Vb 4
\& cd AppName
\& msyqladmin create app_db -u root -p
\& mysql -u root -p app_db < docs/schema.mysql
\& ./app.server -d=mysql --u=regular_user -p='secret' -n=app_db
.Ve
.PP
Then the app is running, you can view it by pointing your browser
to any of the URLs app.server printed on startup.
.SH "A Simple Greeting"
.IX Header "A Simple Greeting"
This section is for those who prefer a less magical experience.
.PP
All you need for a gantry app is a module which uses Gantry and has
a method called do_something (usually do_main is a good first choice):
.PP
.Vb 2
\& package HiWorld;
\& use strict; use warnings;
.Ve
.PP
.Vb 1
\& use base 'Gantry';
.Ve
.PP
.Vb 2
\& sub do_main {
\& my $self = shift;
.Ve
.PP
.Vb 2
\& return "Hello, Rob";
\& }
.Ve
.PP
.Vb 1
\& 1;
.Ve
.PP
I'll store this module in /home/myhome/lib/HiWorld.pm. I'll need
to set that lib path with a use lib below.
.SH "Stand Alone Server Deployment"
.IX Header "Stand Alone Server Deployment"
If you have HTTP::Server::Simple installed, you may choose to deploy
your application through it. This is useful for kick starting development.
See below for more permanent means of deployment.
.PP
A stand alone Gantry application is an executable script which leverages
Gantry::Server (which in turn uses HTTP::Server::Simple). This one
is enough for our small demo:
.PP
.Vb 2
\& #!/usr/bin/perl
\& use strict;
.Ve
.PP
.Vb 1
\& use Gantry::Server;
.Ve
.PP
.Vb 1
\& use lib '/home/myhome/lib';
.Ve
.PP
.Vb 1
\& use HiWorld qw{ -Engine=CGI -TemplateEngine=Default };
.Ve
.PP
.Vb 1
\& my $cgi = Gantry::Engine::CGI->new();
.Ve
.PP
.Vb 1
\& $cgi->add_location( '/', 'HiWorld' );
.Ve
.PP
.Vb 2
\& my $port = shift || 8080;
\& my $server = Gantry::Server->new( $port );
.Ve
.PP
.Vb 2
\& $server->set_engine_object( $cgi );
\& $server->run();
.Ve
.PP
If you used Bigtop, as in the first section of this document, it made
\&\f(CW\*(C`app.server\*(C'\fR which is similar to this one.
.SH "CGI Deployment"
.IX Header "CGI Deployment"
To deploy using \s-1CGI\s0, create the following script in a servable
cgi-bin directory (remember to make sure it is executable):
.PP
.Vb 2
\& #!/usr/bin/perl
\& use strict;
.Ve
.PP
.Vb 1
\& use CGI::Carp qw( fatalsToBrowser);
.Ve
.PP
.Vb 1
\& use lib '/home/myhome/lib';
.Ve
.PP
.Vb 1
\& use HiWorld qw{ -Engine=CGI -TemplateEngine=Default };
.Ve
.PP
.Vb 1
\& my $cgi = Gantry::Engine::CGI->new();
.Ve
.PP
.Vb 1
\& $cgi->add_location( '/', 'HiWorld' );
.Ve
.PP
.Vb 1
\& $cgi->dispatch();
.Ve
.PP
Then point your browser to the script.
.PP
If you used Bigtop to generate the application, as shown in the first
section above, it made \f(CW\*(C`app.cgi\*(C'\fR for you. You can deploy to \s-1CGI\s0 by
copying that file into your web server's \f(CW\*(C`cgi\-bin\*(C'\fR directory, if you also:
.IP "install the app" 4
.IX Item "install the app"
The HiRob.pm module must be installed somewhere in the \f(CW@INC\fR path,
or you must add a \f(CW\*(C`use lib\*(C'\fR statement in your \s-1CGI\s0 script which includes
the directry where the module lives.
.IP "set permissions correctly" 4
.IX Item "set permissions correctly"
First, the web server must be able to read the build directory and its
sub directories. (If you have an sqlite database, you must make
both the database and the build directory writable by the web server.)
.IP "beware of selinux" 4
.IX Item "beware of selinux"
Tools like selinux exist to keep people from accessing things. As such,
they will probably block users from seeing things in your build directory
via a web server. Either disable it, or move things to appropriate
places it allows the web server to access.
.PP
See \*(L"What is Gantry::Conf\*(R" and \*(L"How do I use Gantry::Conf under CGI/FastCGI\*(R"
in Gantry::Docs::FAQ for information on switching the \s-1CGI\s0 script to
a different database.
.SH "mod_perl Deployment"
.IX Header "mod_perl Deployment"
To use mod_perl, you must have permission to modify the httpd.conf for your
web server and to restart it. Here is the virtual host I created
for the greeting application:
.PP
.Vb 1
\&
.Ve
.PP
.Vb 4
\& ServerName hiworld.devel.example.com
\& DocumentRoot /home/myhome/html/play
\& CustomLog /home/myhome/logs/combined.log combined
\& ErrorLog /home/myhome/logs/hiworld.err
.Ve
.PP
.Vb 1
\& Include /home/myhome/html/play/hiworld.conf
.Ve
.PP
.Vb 1
\&
.Ve
.PP
This throws the real config work to hiworld.conf. Mine assumes
mod_perl 1.3. Here it is:
.PP
.Vb 2
\&
\& #!/usr/bin/perl
.Ve
.PP
.Vb 1
\& use lib '/home/pcrow/srcgantry/play';
.Ve
.PP
.Vb 2
\& use HiWorld qw{ -Engine=MP13 -TemplateEngine=Default };
\&
.Ve
.PP
.Vb 4
\&
\& SetHandler perl-script
\& PerlHandler HiWorld
\&
.Ve
.PP
After restarting the server, I can point my browser to
.PP
.Vb 1
\& http://hiworld.devel.example.com/hello
.Ve
.PP
to see the greeting.
.PP
If you are using mod_perl 2, simply change the use statement to:
.PP
.Vb 1
\& use HiWorld qw{ -Engine=MP20 -TemplateEngine=Default };
.Ve
.PP
(i.e. replace \s-1MP13\s0 with \s-1MP20\s0)
.PP
Note that if other Gantry apps are running in the same server instance,
they may fight over which template engine to use. Generally, the
first app to put in a use statement for its base module chooses the
template engine. We don't mind this since we always use \s-1TT\s0. Even after
you have chosen \s-1TT\s0, you can turn it off by adding statements like these
to the top of your do_* method.
.PP
.Vb 2
\& $self->content_type( 'text/xml' );
\& $self->template_disable( 1 );
.Ve
.SH "What To Do Now"
.IX Header "What To Do Now"
Once you have your first app running, as shown above, you are ready to
move on in the following sequence of documents:
.IP "1." 4
Gantry::Docs::Tutorial
.IP "2." 4
Bigtop::Docs::Tutorial
.PP
After those, you probably want Gantry::Docs::FAQ,
Gantry::Docs::Cookbook, or Bigtop::Docs::Cookbook.
.SH "Author"
.IX Header "Author"
Phil Crow
.SH "Copyright and License"
.IX Header "Copyright and License"
Copyright (c) 2006\-7, Phil Crow.
.PP
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6 or,
at your option, any later version of Perl 5 you may have available.