CGI::Ap...ntroller(3)

πŸ“¦ version 0.015, in fedora 43, fedora 44

πŸ’– CGI::Ap...ntroller(3) β€” the glow-up edition πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation crew, and it's all about CGI::Ap...ntroller (yes that's the truncated name, she's mysterious like that ✨). Buckle up, we're building controllers. πŸŽ€


✨ NAME ✨

Template controller creation helper for CGI::Application::Structured apps. that's it, that's the job, and she does it flawlessly πŸ’…


✨ SYNOPSYS ✨

(keeping the original spelling because I don't fight with the ancestors πŸ™ˆ)

cd $PROJECT_ROOT_DIRECTORY

~/tmp/MyApp1$ perl script/create_controller.pl  --name="Conrtoller2"
will try to create lib/MyApp1/C
Created lib/MyApp1/C/Conrtoller2.pm
will try to create template directory templates/MyApp1/C/Conrtoller2
Created templates/MyApp1/C/Conrtoller2
Created templates/MyApp1/C/Conrtoller2/index.tmpl

look at her go. no notes. πŸ”₯


✨ DESCRIPTION ✨

so what actually happens when you run this? glad you asked 🫢

This will produce a subclass of your main application module, create a default runmode for it, and generate a default TT template for the default runmode. Restart server.pl and you can run that controller at:

http://localhost:8060/cgi-bin/index.cgi/controller2

The result will be a page with the title "controller2" and an HTML H2 element with the text "Hello world!". icon behavior honestly πŸ‘‘

Also generate an index.tmpl for the new controller and puts it in the directory tree rooted in the 'templates' directory of the projects root directory. The directory structure of the 'templates' directory should mirror that of the path under 'lib' for the associated controller. like, mirrors. matching. as above so below. πŸͺž

This script was generated by cas-starter.pl from CGI::Application::Structured::Tools package.


πŸ¦‹ the little helper functions (they're the main characters too) πŸ¦‹

  • create_file($path, $contents) β€” Utility to create a file given it's path and desired contents. short king, does one thing, does it perfectly. πŸ’œ
  • get_template_path β€” Given a template name, finds it's full path in the CGI::Application::Structured::Tools template distribution. she knows where everything lives. iykyk. 🧚
  • create_submodule($module_name) β€” Given a partial module name, generates a module by prepending the applications main module name + "::C::" to $module_name to create the fully qualified package for the new controller module. it's giving frankenstein but make it namespace 🌸
  • create_tt($module_name) β€” Given a module name it generates a Template Toolkit template for the 'index' runmode. The template is generated into the applications 'templates' directory. The nested directory structure reflects the director structure for your modules under the 'lib' directory. (yes, director structure, the original said it, I'm not touching it, periodt 😭)

✨ Examples" ✨

(yes there is a stray quote mark in the original heading and I am preserving her legacy πŸ’–)

gordon@govitoshi:~/tmp$ find MyApp1/lib/
MyApp1/lib/
MyApp1/lib/MyApp1.pm
MyApp1/lib/MyApp1
MyApp1/lib/MyApp1/C
MyApp1/lib/MyApp1/C/Home.pm
MyApp1/lib/MyApp1/C/Control2.pm
MyApp1/lib/MyApp1/Dispatch.pm

gordon@govitoshi:~/tmp$ find MyApp1/templates
MyApp1/templates
MyApp1/templates/MyApp1
MyApp1/templates/MyApp1/C
MyApp1/templates/MyApp1/C/Control2
MyApp1/templates/MyApp1/C/Control2/index.tmpl
MyApp1/templates/MyApp1/C/Home
MyApp1/templates/MyApp1/C/Home/index.tmpl

see how the lib tree and the templates tree are in their synchronized era?? that's the whole vibe check right there. slay. 🌈


✨ AUTHOR ✨

Gordon Van Amburg
CPAN ID: VANAMBURG
vanamburg at cpan.org

shoutout to Gordon, the blueprint, the moment πŸ’


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

bestie, license stuff is not the part you skip. read the LICENSE file. it's right there. be a good citizen. 🫑

okay that's the whole page!! πŸŽ€ this came to you via perl v5.42.0, dated 2025-07-25, and it's filed under CGI::Ap...ntroller(3) β€” go forth and generate controllers, you absolute icon πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from