NAME

SweetPea - A simple light-weight web application framework based on an MVC design pattern using only CGI!

VERSION

Version 2.02

SYNOPSIS

SweetPea is designed primarily as a KISS (keep it simple stupid) web framework. SweetPea was designed using some of my favorite functions from Mojo and Catalyst. The need for SweetPea arose after performing a contrast and comparison between various web frameworks, specifically focusing on the CPAN modules available to Perl developers. SweetPea is a web framework that requires little to no configuration (PnP) but handles all the standard web application facilities as well as an MVC design pattern. So heres my take on an easy-to-use web framework.

using SweetPea is as easy as ...

... from the cli (command line interface)

perl -MSweetPea -e makeapp

Created file /sweet/App.pm (chmod 755) ...
Created file /.pl (chmod 755) ...
Created file /.htaccess (chmod 755) ...
Created file /sweet/application/Controller/Root.pm (chmod 754) ...
Created file /sweet/application/Model/Schema.pm (chmod 754) ...
Created file /sweet/application/View/Main.pm (chmod 754) ...
Created file /sweet/application/Controller/Sweet.pm (chmod 754) ...

... in the .pl script file generated by the makeapp method (http://localhost/.pl/sweet/welcome) which is
masked by the an htaccess file if using apache (enables pretty-urls) e.g.
(http://localhost/sweet/welcome).

use SweetPea;
my $s = SweetPea->new->run;

# Note! The url pattern is /:controller/:action so http://localhost/sweet/welcome execute the code found in
sweet/application/Controller/Sweet.pm - sub welcome { ... }. Also note that multi-level namespaces are supported, e.g.
http://localhost/admin/users/account/profile will match either Controller::Admin::Users::Account::Profile::_index() or
Controller::Admin::Users::Account::profile() or else default to Controller::Root::_index()

EXPORT

makeapp (application generation)

METHODS

new

The new method initializes a new SweetPea object.

run

The run method, well, does what it says, it initializes and runs the application.

start

The start method should probably be named (startup) because it is the method which configures the environment and performs various startup tasks.

finish

The finish method performs various cleanup tasks after the request reaches its end.

forward

The forward method executes a method from within another class, then continues to execute instructions in the method it was called from.

detach

The detach method executes a method from within another class, then immediately executes the special "end" method which finalizes the request.

store

The store method is in accessor to the special "store" hashref.

application

The application method is in accessor to the special "application" hashref.

content_type

The content_type method set the desired output format for use with http headers

uri

The uri method returns the base uri of the application.

cookies

Returns a list of cookies set throughout the duration of the request.

html

The html method sets data to be output to the browser or if called with no parameters returns the data recorded and clears the data store.

debug

The debug method sets data to be output to the browser with additional information for debugging purposes or if called with no parameters returns the data recorded and clears the data store.

output

This method should be used with the debug or html methods to exit the application and spit out the passed in output.

plug

This function creates accessors for third party (non-core) modules, e.g. $self->plug('email', sub{ return Email::Stuff->new(...) });

makeapp

This function is exported an intended to be called from the command-line. This creates the boiler plate appication structure.

AUTHOR

Al Newkirk, <al at alnewkirk.com>

BUGS

Please report any bugs or feature requests to bug-sweetpea at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SweetPea. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc SweetPea

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks to all the developers of Mojolicious and Catalyst that inspired this.

COPYRIGHT & LICENSE

Copyright 2009 Al Newkirk.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.