NAME
Egg - WEB Application Framework.
SYNOPSIS
# The helper script is generated.
perl -MEgg::Helper -e 'Egg::Helper->out' > egg_helper.pl
# The project is generated.
perl egg_helper.pl Project MyApp
# Confirming the operation of project.
./MyApp/bin/tirigger.cgi
# The project object is acquired.
use lib './MyApp/lib';
require MyApp;
my $e= MyApp->new;
DESCRIPTION
Egg is WEB application framework.
The composition of the module operates at comparatively simply and high speed.
It is MVC framework of model and view and controller composition.
* It was a plug-in etc. and there were Catalyst and some interchangeability in the version before. Interchangeability was completely lost from the change of the method name in this version. However, there might not be transplant in the difficulty.
CONFIGURATION
The setting of the configuration of Egg is a method of passing HASH to the method of 'egg_startup' directly and the definition. There is a method to read to a semiautomatic target by it and 'Egg::Plugin::ConfigLoader'.
Please refer to the document of Egg::Plugin::ConfigLoader for details.
root
Route PATH of project.
* It is not route PATH of the template.
* There is no default. Please set it.
title
Title of project.
Default is a class name of the project.
content_type
Contents type used by default.
Default is 'text/html'.
content_language
Language used by default
There is no default.
template_extention
Extension of template used by default.
* There is no '.' needing.
Default is 'tt'.
template_default_name
Template name used by default.
Default is 'index'.
static_uri
Route URI for static contents.
* Please end by '/'.
Default is '/'.
template_path
Passing for template.
* The thing set by the ARRAY reference can be done.
* There is no default. Please set it.
dir
PATH setting of various folders.
lib
Local PATH where library of project is put.
Default is '< $e.root >/lib'.
static
Local PATH where static contents are put.
Default is '< $e.root >/htdocs'.
etc
For preservation of configuration file etc.
Default is '< $e.root >/etc'.
cache
For preservation of cash data.
Default is '< $e.root >/cache'.
template
The main template depository.
Default is '< $e.root >/root'.
comp
Template depository for include.
Default is '< $e.root >/comp'.
tmp
Temporary work directory PATH.
Default is '< $e.root >/tmp'.
lib_project
Project directory PATH in dir->{lib}.
Egg compulsorily sets it based on the value of dir->{lib}.
root
Copy of root.
accessor_names
The accessor to stash is generated with the set name.
MODEL
It is a setting of MODEL. As for the content, the setting of each MODEL becomes ARRAY further by ARRAY, too. The setting of the first is treated as MODEL of default.
MODEL => [
[ DBI => {
dsn => '.....',
user => '...',
...
} ],
],
VIEW
It is a setting of VIEW. As for the content, the setting of each VIEW becomes ARRAY further by ARRAY, too. The setting of the first is treated as VIEW of default.
VIEW => [
[ Mason => {
comp_root => [ ... ],
data_dir => '...',
} ],
],
... others.
Please refer to the module document of each object for other settings.
METHODS
namespace
The project name under operation is returned.
config
Configuration is returned by the HASH reference.
request
The request object is returned.
Alias: req
response
The response object is returned.
Alias: res
dispatch
The dispatch object is returned.
* It is necessary to load the plug-in with the dispatch method. Egg::Plugin::Dispatch::Standard and Egg::Plugin::Dispatch::Fast are prepared by the standard.
log
The log object is returned.
* When the plugin with the log method is not loaded, Egg::DummyLog is used. - new, notes, debug, error
egg_startup ( [CONFIG_HASH] )
Necessary for operating the project prior is prepared.
CONFIG_HASH is set to 'config' method. If Egg::Plugin::ConfigLoader is loaded, it is CONFIG_HASH omissible. However, it is a thing that the configuration file is arranged in an appropriate place in this case.
__PACKAGE__->egg_startup;
is_model ( [MODEL_NAME] )
If specified MODEL is loaded, the package name is returned.
is_view ( [VIEW_NAME] )
If specified VIEW is loaded, the package name is returned.
models
The loaded MODEL name list is returned by the ARRAY reference.
views
The loaded VIEW name list is returned by the ARRAY reference.
model_class
The loaded MODEL management data is returned by the HASH reference.
view_class
The loaded VIEW management data is returned by the HASH reference.
regist_model ( [MODEL_NAME], [PACKAGE_NAME], [INCLUDE_FLAG] )
The use of specified MODEL is enabled.
* MODEL_NAME is not omissible.
* PACKAGE_NAME is an actual package name of object MODEL. Egg::Model::[MODEL_NAME] is used when omitting it.
* If INCLUDE_FLAG is true, require is done at the same time.
$e->regist_model('MyModel', 'MyApp::Model::MyModel', 1);
regist_view ( [VIEW_NAME], [PACKAGE_NAME], [INCLUDE_FLAG] )
The use of specified VIEW is enabled.
* VIEW_NAME is not omissible.
* PACKAGE_NAME is an actual package name of object VIEW. Egg::View::[VIEW_NAME] is used when omitting it.
* If INCLUDE_FLAG is true, require is done at the same time.
$e->regist_view('MyView', 'MyApp::View::MyView', 1);
default_model ( [MODEL_NAME] )
The MODEL name of default is returned. * A high setting of the priority level defaults most and it is treated.
Default is temporarily replaced when MODEL_NAME is specified, and the object of the MODEL is returned.
default_view ( [VIEW_NAME] )
The VIEW name of default is returned. * A high setting of the priority level defaults most and it is treated.
Default is temporarily replaced when VIEW_NAME is specified, and the object of the VIEW is returned.
model ( [MODEL_NAME] )
The object of specified MODEL is returned.
When MODEL_NAME is omitted, the MODEL object of default is returned.
view ( [VIEW_NAME] )
The object of specified VIEW is returned.
When VIEW_NAME is omitted, the VIEW object of default is returned.
run
The project is completely operated, and the result code is returned at the end.
* Do not call this method from the code inside of the project.
stash ( [KEY_NAME] )
The value of the common data specified with KEY_NAME is returned.
When KEY_NAME is omitted, the common data is returned by the HASH reference.
flag ( [FLAG_NAME] )
The value of the flag specified with FLAG_NAME is returned.
path ( [CONF_KEY], [PATH] )
The result of combining the value of $e->config->{dir} specified with CONF_KEY with PATH is returned.
$e->path('static', 'images/any.png'); => /path/to/myapp/htdocs/images/any.png
uri_to ( [URI], [ARGS_HASH] )
The URI object generated based on [URI] is returned.
The URI object of the query_form setting when ARGS_HASH is passed is returned.
page_title ( [TITLE_STRING] )
The value set to $e->dispatch->page_title is returned. $e->config->{title} is returned if there is no setting.
The title can be set by passing TITLE_STRING.
finished ( [RESPONSE_STATUS], [ERROR_MSG] )
$e->reqonse->status is set when RESPONSE_STATUS is passed and finished is made effective.
RESPONSE_STATUS is 500 or $e->log->error is done any more. At this time, if ERROR_MSG has been passed, it is included in the argument.
0 It is $e->reqonse->status(0) when is passed, and finished is invalidated.
snip
$e->request->snip is returned.
action
$e->dispatch->action is returned.
debug
The state of the debugging flag is returned.
mp_version
$Egg::Request::MP_VERSION is returned.
debug_out ( [MESSAGE] )
If the debugging flag is effective, MESSAGE is output to STDERR.
Nothing is done usually.
OPERATION METHODS
When the project module is read, Egg generates the handler method. And, dynamic contents are output from the handler method via the following method calls and processing is completed.
_start_engine
If $e->debug is effective, it replaces with _ start_engine_debug. After the call of each method, '_start_engine_debug' measures the execution time. This measurement result is reported to STDERR at the end of processing.
_prepare_model
Prior because MODEL is operated is prepared.
_prepare_view
Prior because VIEW is operated is prepared.
_prepare
It is a prior hook for the plugin.
_dispatch_start
It is a prior hook for dispatch.
If it is effective, $e->finished has not already done anything.
_dispatch_action
It is a hook for correspondence action of dispatch.
If it is effective, $e->finished has not already done anything.
If an appropriate template has been decided, and $e->response->body is undefined, $e->view->output is done.
_dispatch_finish
It is a hook after the fact for dispatch.
If it is effective, $e->finished has not already done anything.
_finalize
It is a hook after the fact for the plugin.
_finalize_output
If it seems to complete the output of contents that are effective $e->finished and have defined $e->response->{header}, nothing is done.
Contents are output, and $e->finished is set.
_finalize_error
When some errors occur by '_start_engine', it is called.
The plug-in for which the processing when the error occurs is necessary prepares this method.
This method finally writes the log, and outputs contents for debugging.
_finalize_result
They are the last processing most.
$e->response->result is called and the Result code is returned.
SUPPORT
Distribution site.
L<http://egg.bomcity.com/>.
sourcefoge project.
L<http://sourceforge.jp/projects/egg/>.
SEE ALSO
Egg::Base, Egg::Request, Egg::Response, Egg::Model, Egg::View, Egg::Release,
AUTHOR
Masatoshi Mizuno <lushe@cpan.org>
COPYRIGHT
Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.