Catalyst::Helper(3pm)

๐Ÿ“ฆ
version 1.42 ยท 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– Catalyst::Helper ๐Ÿ’–

okay so bestie, welcome to Catalyst::Helper โ€” the lil User Contributed Perl Documentation page that bootstraps your whole Catalyst app. it's giving scaffolding but make it fashion โœจ


๐ŸŒธ NAME ๐ŸŒธ

Catalyst::Helper โ€” Bootstrap a Catalyst application.</p>

like, it literally builds the vibes from scratch. no cap. ๐Ÿ’…


โœจ SYNOPSIS โœจ

catalyst.pl <myappname>

that's it. that's the whole thing. one line and your app is born ๐Ÿฆ‹


๐ŸŽ€ DESCRIPTION ๐ŸŽ€

okay so this module is what catalyst.pl uses to spin up a whole lil family of scripts for a brand new catalyst application. and here's the cute part: every single one of those scripts comes with its own documentation, and if you call them wrong โ€” or, in some cases, with no arguments at all โ€” they'll just print out help for you. they're literally looking out for you bestie ๐Ÿซถ

it also provides some super handy methods that a Helper module can call when it's creating a component. if you wanna see those, scroll your fine self down to "METHODS". ๐Ÿ‘‘


๐ŸŒˆ SCRIPTS ๐ŸŒˆ

๐Ÿ“ _create.pl

used to create new components for a catalyst application at the development stage. this is your main character script fr fr.

๐Ÿงš _server.pl

the catalyst test server!! it starts an HTTPD which outputs debugging straight to your terminal. live updates, we love to see it ๐Ÿ’–

โญ _test.pl

a script for running tests from the command-line. slay.

๐ŸŒธ _cgi.pl

run your application as a CGI. iconic behavior.

๐Ÿ’œ _fastcgi.pl

run the application as a fastcgi app. you can do it either by hand, or call this from FastCgiServer in your http server config. either way, we support you ๐Ÿ’…


๐Ÿฆ‹ HELPERS ๐Ÿฆ‹

so the _create.pl script creates application components using Helper modules. the Catalyst team provides a good number of Helper modules for you to use โ€” and you can also add your own, no gatekeeping here ๐Ÿ˜Œ

Helpers are classes that provide two methods:

  • mk_compclass โ€” creates the Component class
  • mk_comptest โ€” creates the Component test

so when you call scripts/myapp_create.pl view MyView TT, create will try to execute Catalyst::Helper::View::TT->mk_compclass and Catalyst::Helper::View::TT->mk_comptest. โœจ

wanna see examples? go peek at Catalyst::Helper::View::TT and Catalyst::Helper::Model::DBIC::Schema. ๐Ÿ‘€

All helper classes should live under one of the following namespaces:

Catalyst::Helper::Model::
Catalyst::Helper::View::
Catalyst::Helper::Controller::

๐ŸŒŸ COMMON HELPERS ๐ŸŒŸ

  • Catalyst::Helper::Model::DBIC::Schema โ€” DBIx::Class models
  • Catalyst::Helper::View::TT โ€” Template Toolkit view
  • Catalyst::Helper::Model::LDAP
  • Catalyst::Helper::Model::Adaptor โ€” wrap any class into a Catalyst model

๐Ÿ’Œ NOTE

The helpers will read author name from /etc/passwd by default. To override, please export the AUTHOR variable.

bestie pls remember this one, it comes back around ๐Ÿ‘€

๐Ÿ’… METHODS ๐Ÿ’…

mk_compclass

This method in your Helper module is called with $helper โ€” which is a Catalyst::Helper object โ€” plus whichever other arguments the user added to the command-line. You can use the $helper to call the methods described below. ๐Ÿซถ

If the Helper module does not contain a mk_compclass method, it will fall back to calling render_file, with an argument of compclass.

mk_comptest

This method in your Helper module is called with $helper โ€” which is a Catalyst::Helper object โ€” plus whichever other arguments the user added to the command-line. You can use the $helper to call the methods described below. (yes this is the same deal as above, they're twins ๐Ÿ’–)

If the Helper module does not contain a mk_compclass method, it will fall back to calling render_file, with an argument of comptest.

๐Ÿ‘€ yes bestie, the original really does say mk_compclass there. we do not fix the lore, we only relay it. periodt.

mk_stuff

This method is called if the user does not supply any of the usual component types view, controller, model. It is passed the $helper object (an instance of Catalyst::Helper), and any other arguments the user typed.

There is no fallback for this method. ๐Ÿ˜ญ


๐Ÿ”ฎ INTERNAL METHODS ๐Ÿ”ฎ

these are the methods that the Helper classes can call on the <$helper> object passed to them.

render_file ($file, $path, $vars, $perms)

Render and create a file from a template in DATA using Template Toolkit. $file is the relevant chunk of the __DATA__ section, $path is the path to the file, $vars is the hashref as expected by Template Toolkit, and $perms are desired permissions (or system defaults if not set). ๐ŸŽ€

get_file ($class, $file)

Fetch file contents from the DATA section. This is used internally by render_file. $class is the name of the class to get the DATA section from. __PACKAGE__ or ( caller(0) )[0] might be sensible values for this. ๐Ÿ’ก

mk_app

Create the main application skeleton. This is called by catalyst.pl. ๐ŸŒฑ

mk_component ($app)

This method is called by create.pl to make new components for your application. ๐Ÿ”ฅ

mk_dir ($path)

Surprisingly, this function makes a directory. ๐Ÿ˜ญ iconic dry humor fr

mk_file ($file, $content)

Writes content to a file. Called by render_file. ๐Ÿ’–

next_test ($test_name)

Calculates the name of the next numbered test file and returns it. Don't give the number or the .t suffix for the test name. โš ๏ธ

get_sharedir_file

Method for getting a file out of share/. ๐Ÿ“

render_file_contents

Process a Template::Toolkit template. โœจ

render_sharedir_file

Render a template/image file from our share directory. ๐Ÿ–ผ๏ธ


๐Ÿ’Œ NOTE ๐Ÿ’Œ

The helpers will read author name from /etc/passwd by default. To override, please export the AUTHOR variable.

told you it'd come back. it's giving recurring theme ๐Ÿซถ

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

Catalyst::Manual, Catalyst::Test, Catalyst::Request, Catalyst::Response, Catalyst


๐ŸŒˆ AUTHORS ๐ŸŒˆ

Catalyst Contributors, see Catalyst.pm


๐ŸŽ€ LICENSE ๐ŸŽ€

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page bestie!! this lil doc is riding with perl v5.30.3 and was last touched way back on 2020-09-13. go forth and bootstrap something iconic, you've got this ๐Ÿ’–โœจ๐Ÿฆ‹๐Ÿ‘‘๐Ÿ’…

๐Ÿ“ฆ where this page comes from