NAME
SweetPea - A simple light-weight web application framework based on an MVC design pattern using only CGI!
VERSION
Version 2.00
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
Creating...
sweet/application/Model/
sweet/application/View/
sweet/application/Controller/
sweet/application/App.pm
sweet/sessions/
sweet/
static/
.htaccess
.pl
... 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
A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented module.
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.
_plugins
The plugins method is an internal method (not to be called externally) that sets up module accessors.
_load_path_and_actions
The _load_path_and_actions method is an internal method that scans the controller folder and creates a list of controllers and methods for routing, forwarding, detaching and otherwise loading methods dynamically.
_self_check
This _self_check method is an internal method that verifies that all the required elements are in place to ensure a happy execution.
_init_dispatcher
The _init_dispatcher method is an internal method that loads all the applications methods and determines which methods to use.
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.
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.
template
This method sets the template for rendering
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.
NAME
Controller::Root - Root Controller (Must Exist)
NAME
Controller::Sweet - SweetPea Introduction and Welcome Page
welcome
This function displays a simple information page the application defaults to before development. This module should be removed before development.
NAME
Model::Schema - Database Class Encapsulation
NAME
View::Main - Main Template Rendering Class Encapsulation
NAME
App - This module loads all third party modules and provides accessors to the calling module!
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:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
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.