environment where we can explore a variety of features used in virtually
all web applications.
-Source code for the tutorial in included in the F</root/Final> directory
-of the Tutorial Virtual machine (one subdirectory per chapter). There
-are also instructions for downloading the code in
+Source code for the tutorial in included in the F</home/catalyst/Final>
+directory of the Tutorial Virtual machine (one subdirectory per
+chapter). There are also instructions for downloading the code in
L<Catalyst::Manual::Tutorial::01_Intro>.
Please take a look at
=head1 EDIT THE LIST OF CATALYST PLUGINS
One of the greatest benefits of Catalyst is that it has such a large
-library of bases classes and plugins available that you can use easily
+library of base classes and plugins available that you can use to easily
add functionality to your application. Plugins are used to seamlessly
integrate existing Perl modules into the overall Catalyst framework. In
general, they do this by adding additional methods to the C<context>
Catalyst> line of your application class will be plugins, Catalyst
supports a limited number of flag options (of these, C<-Debug> is the
most common). See the documentation for
-C<https://metacpan.org/module/Catalyst|Catalyst.pm> to get details on
+L<https://metacpan.org/module/Catalyst|Catalyst.pm> to get details on
other flags (currently C<-Engine>, C<-Home>, C<-Log>, and C<-Stats>).
If you prefer, there are several other ways to enable debug output:
=item *
-Use the C<$c-E<gt>debug> method on the C<$c> Catalyst context object
+the C<$c-E<gt>debug> method on the C<$c> Catalyst context object
=item *
-The C<-d> option to C<script/myapp_server.pl>
+the C<-d> option on the C<script/myapp_server.pl> script
=item *
-The C<CATALYST_DEBUG=1> environment variable (or use C<CATALYST_DEBUG=0>
-to temporarily disable debug output).
+the C<CATALYST_DEBUG=1> environment variable (or C<CATALYST_DEBUG=0>
+to temporarily disable debug output)
=back
=back
-For our application, we want to add one new plugin into the mix. To do
+For our application, we want to add one new plugin to the mix. To do
this, edit C<lib/MyApp.pm> (this file is generally referred to as your
I<application class>) and delete the lines with:
screen that starts with "Caught exception in
MyApp::Controller::Root->index" with sections showing a stacktrace,
information about the Request and Response objects, the stash (something
-we will learn about soon), the applications configuration configuration.
+we will learn about soon), and the applications configuration.
B<Just don't forget to remove the die before you continue the tutorial!>
:-)
actions:
$ script/myapp_create.pl controller Books
- exists "/root/MyApp/script/../lib/MyApp/Controller"
- exists "/root/MyApp/script/../t"
- created "/root/MyApp/script/../lib/MyApp/Controller/Books.pm"
- created "/root/MyApp/script/../t/controller_Books.t"
+ exists "/home/catalyst/MyApp/script/../lib/MyApp/Controller"
+ exists "/home/catalyst/MyApp/script/../t"
+ created "/home/catalyst/MyApp/script/../lib/MyApp/Controller/Books.pm"
+ created "/home/catalyst/MyApp/script/../t/controller_Books.t"
Then edit C<lib/MyApp/Controller/Books.pm> (as discussed in
L<Chapter 2|Catalyst::Manual::Tutorial::02_CatalystBasics> of
the Tutorial, Catalyst has a separate directory under C<lib/MyApp> for
-each of the three parts of MVC: C<Model>, C<View>, and C<Controller>)
+each of the three parts of MVC: C<Model>, C<View> and C<Controller>)
and add the following method to the controller:
=head2 list
C<http://localhost:3000/books/list>, but "C<:Path('/list')>" would match
on C<http://localhost:3000/list> (because of the leading slash). You
can use C<:Args()> to specify how many arguments an action should
-accept. See L<Catalyst::Manual::Intro/Action_types> for more
+accept. See L<Catalyst::Manual::Intro/Action-types> for more
information and examples.
=item *
C<TT> style of view rendering:
$ script/myapp_create.pl view HTML TT
- exists "/root/MyApp/script/../lib/MyApp/View"
- exists "/root/MyApp/script/../t"
- created "/root/MyApp/script/../lib/MyApp/View/HTML.pm"
- created "/root/MyApp/script/../t/view_HTML.t"
+ exists "/home/catalyst/MyApp/script/../lib/MyApp/View"
+ exists "/home/catalyst/MyApp/script/../t"
+ created "/home/catalyst/MyApp/script/../lib/MyApp/View/HTML.pm"
+ created "/home/catalyst/MyApp/script/../t/view_HTML.t"
This creates a view called C<HTML> (the first argument) in a file called
C<HTML.pm> that uses L<Catalyst::View::TT> (the second argument) as the
Please stick with the settings above for the duration of the tutorial,
but feel free to use whatever options you desire in your applications
-(as with most things Perl, there's more than one way to do it...).
+(as with most things in Perl, there's more than one way to do it...).
B<Note:> We will use C<root/src> as the base directory for our template
files, with a full naming convention of
$ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \
create=static dbi:SQLite:myapp.db \
on_connect_do="PRAGMA foreign_keys = ON"
- exists "/root/MyApp/script/../lib/MyApp/Model"
- exists "/root/MyApp/script/../t"
- Dumping manual schema for MyApp::Schema to directory /root/MyApp/script/../lib ...
+ exists "/home/catalyst/MyApp/script/../lib/MyApp/Model"
+ exists "/home/catalyst/MyApp/script/../t"
+ Dumping manual schema for MyApp::Schema to directory /home/catalyst/MyApp/script/../lib ...
Schema dump completed.
- created "/root/MyApp/script/../lib/MyApp/Model/DB.pm"
- created "/root/MyApp/script/../t/model_DB.t"
+ created "/home/catalyst/MyApp/script/../lib/MyApp/Model/DB.pm"
+ created "/home/catalyst/MyApp/script/../t/model_DB.t"
Please note the '\' above. Depending on your environment, you might be
able to cut and paste the text as shown or need to remove the '\'
Additionally, the C<lib/MyApp/Schema.pm> model can easily be loaded
outside of Catalyst, for example, in command-line utilities and/or cron
jobs. C<lib/MyApp/Model/DB.pm> provides a very thin "bridge" between
-Catalyst this external database model. Once you see how we can add some
-powerful features to our DBIC model in
+Catalyst and this external database model. Once you see how we can
+add some powerful features to our DBIC model in
L<Chapter 4|Catalyst::Manual::Tutorial::04_BasicCRUD>, the elegance
of this approach will start to become more obvious.
=head1 ENABLE THE MODEL IN THE CONTROLLER
Open C<lib/MyApp/Controller/Books.pm> and un-comment the model code we
-left disabled earlier so that your version matches the following (un-
-comment the line containing C<[$c-E<gt>model('DB::Book')-E<gt>all]> and
-delete the next 2 lines):
+left disabled earlier so that your version matches the following
+(un-comment the line containing C<[$c-E<gt>model('DB::Book')-E<gt>all]>
+and delete the next 2 lines):
=head2 list
[debug] Loaded dispatcher "Catalyst::Dispatcher"
[debug] Loaded engine "Catalyst::Engine"
- [debug] Found home "/root/MyApp"
- [debug] Loaded Config "/root/MyApp/myapp.conf"
+ [debug] Found home "/home/catalyst/MyApp"
+ [debug] Loaded Config "/home/catalyst/MyApp/myapp.conf"
[debug] Loaded components:
.-----------------------------------------------------------------+----------.
| Class | Type |
$ DBIC_TRACE=1 script/myapp_server.pl -r
Make sure that the application loads correctly and that you see the
-three dynamically created model class (one for each of the Result
+three dynamically created model classes (one for each of the Result
Classes we created).
Then hit the URL L<http://localhost:3000/books/list> with your browser
information that can appear in that field (and can therefore inject
markup or code if you don't "neutralize" those fields). In addition to
"| html", Template Toolkit has a variety of other useful filters that
-can found in the documentation for L<Template::Filters>. (While we are
-on the topic of security and escaping of dangerous values, one of the
-advantages of using tools like DBIC for database access or
+can be found in the documentation for L<Template::Filters>. (While we
+are on the topic of security and escaping of dangerous values, one of
+the advantages of using tools like DBIC for database access or
L<HTML::FormFu> for form management [see
-L<Chapter 9|Catalyst::Manual::Tutorial::09_AdvancedCRUD::09_FormFu>
+L<Chapter 9|Catalyst::Manual::Tutorial::09_AdvancedCRUD::09_FormFu>]
is that they automatically handle most escaping for you and therefore
dramatically increase the security of your app.)
In some situations, it can be useful to run your application and display
a page without using a browser. Catalyst lets you do this using the
-C<scripts/myapp_test.pl> script. Just supply the URL you wish to
+C<script/myapp_test.pl> script. Just supply the URL you wish to
display and it will run that request through the normal controller
dispatch logic and use the appropriate view to render the output
(obviously, complex pages may dump a lot of text to your terminal
You should now be able to access the L<http://localhost:3000/books/list>
URL as before.
-B<NOTE:> Please note that if you use the default template technique, you
+B<NOTE:> If you use the default template technique, you
will B<not> be able to use either the C<$c-E<gt>forward> or the
C<$c-E<gt>detach> mechanisms (these are discussed in Chapter 2 and
Chapter 9 of the Tutorial).
-B<IMPORTANT:> Make sure that you do NOT skip the following section
+B<IMPORTANT:> Make sure that you do B<not> skip the following section
before continuing to the next chapter 4 Basic CRUD.