Apache2-WebApp-Toolkit
view release on metacpan or search on metacpan
}
# _ always denotes a private method (not URI accessible)
sub _print_result {
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;
PREREQUISITES
Apache2::Request
AppConfig
Template::Toolkit
Getopt::Long
Params::Validate
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.
GETTING STARTED
HELPER SCRIPTS
Create a new project
$ webapp-project --project_title Project --apache_doc_root /var/www
or
$ webapp-project --config /path/to/conf/webapp.conf
Export project settings to the Unix shell
$ source /path/to/project/.projrc
Create a new class
$ webapp-class --name ClassName
Add a pre-packaged *Extra* to an existing project
$ webapp-extra --install PackageName
Start your application
$ webapp-kickstart
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 *(*.pm)* within this directory are
precompiled into memory when Apache starts/restarts.
B) Base class that can be "included" from other classes. Contains
"_global()" and "_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';
..
# Modules added here will be URI accessible
( run in 3.313 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )