Kelp::Routes::Controller - Routes and controller for Kelp
# config.pl # --------- { modules_init => { Routes => { base => 'MyApp::Controller', router => 'Controller' } } } # MyApp/Controller.pm # ------------------- package MyApp::Controller; use Kelp::Base 'MyApp'; sub shared_method { my $self = shift; # $self is an instance of 'MyApp::Controller' ... } # MyApp/Controller/Users.pm # ------------------------- package MyApp::Controller::Users; use Kelp::Base 'MyApp::Controller'; my read { my $self = shift; # $self is an instance of 'MyApp::Controller::Users' ... }
This router module reblesses a Kelp application into its own controller class. This allows you to structure your web application in a classic object oriented fashion, having $self an instance to the current class rather than the main web application.
$self
You must create a main controller class which inherits from Kelp. Each subsequent class can inherit from this class, taking advantage of any common functionality.
To install Kelp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Kelp
CPAN shell
perl -MCPAN -e shell install Kelp
For more information on module installation, please visit the detailed CPAN module installation guide.