Apache2-WebApp-Toolkit

 view release on metacpan or  search on metacpan

lib/Apache2/WebApp.pm  view on Meta::CPAN

      my ($self, $c, $output) = @_;

      $c->request->content_type('text/html');

      print $output;
      exit;
  }

  # /app/project/foo/bar --> maps to Project::Foo->bar()
  sub bar {
      my ($self, $c) = @_;

      $self->_print_result( $c, $c->stash('baz') );     # output 'qux'
  }

  1;

=head1 PREREQUISITES

  Apache2::Request
  AppConfig
  Template::Toolkit
  Getopt::Long
  Params::Validate

=head1 INSTALLATION

From source:

  $ tar xfz Apache2-WebApp-Toolkit-0.X.X.tar.gz
  $ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib
  $ make
  $ make test
  $ make install

Perl one liner using CPAN.pm:

  $ perl -MCPAN -e 'install Apache2::WebApp'

Use of CPAN.pm in interactive mode:

  $ perl -MCPAN -e shell
  cpan> install Apache2::WebApp
  cpan> quit

Just like the manual installation of Perl modules, the user may need root access during
this process to insure write permission is allowed within the installation directory.

=head1 GETTING STARTED

=head2 HELPER SCRIPTS

=head3 Create a new project

  $ webapp-project --project_title Project --apache_doc_root /var/www

    or

  $ webapp-project --config /path/to/conf/webapp.conf

=head3 Export project settings to the Unix shell

  $ source /path/to/project/.projrc

=head3 Create a new class

  $ webapp-class --name ClassName

=head3 Add a pre-packaged I<Extra> to an existing project

  $ webapp-extra --install PackageName 

=head3 Start your application

  $ webapp-kickstart

=head3 Standard output

  /var/www/project/app                              <-- A
  /var/www/project/app/Project
  /var/www/project/app/Project/Base.pm              <-- B
  /var/www/project/app/Project/Example.pm           <-- C
  /var/www/project/bin
  /var/www/project/bin/startup.pl                   <-- D
  /var/www/project/conf
  /var/www/project/conf/htpasswd                    <-- E
  /var/www/project/conf/httpd.conf                  <-- F
  /var/www/project/conf/webapp.conf                 <-- G
  /var/www/project/htdocs                           <-- H
  /var/www/project/templates/example.tt             <-- I
  /var/www/project/templates/error.tt               <-- J
  /var/www/project/logs                             <-- K
  /var/www/project/logs/access_log
  /var/www/project/logs/errror_log
  /var/www/project/tmp                              <-- L
  /var/www/project/tmp/cache
  /var/www/project/tmp/cache/templates
  /var/www/project/tmp/uploads

A) Application directory.  All classes I<(*.pm)> within this directory are precompiled
into memory when Apache starts/restarts.

B) Base class that can be C<included> from other classes.  Contains C<_global()>
and C<_error()> methods that can be inherited using:

Example:

  use base 'Project::Base';

C) Basic class.

D) This is executed when the Apache server starts.  It's used to reset Perl module search
paths in @INC, preload web application classes, precompile constants, etc.

Example:

  #!/usr/bin/env perl

  $ENV{MOD_PERL} or die "Not running under mod_perl";

  use lib '/var/www/project/app';



( run in 0.698 second using v1.01-cache-2.11-cpan-39bf76dae61 )