2 - Module overview
https://secure.gravatar.com/avatar/b28e536690cbbcc42568497fe280b4f4.png?d=wavatar&s=28
Thu Aug 05 08:29 Authored by zegenie

After running the create_module command to create the hello_world module in the previous step, you now have the basic skeleton directory structure of a module in pachno/modules/hello_world. This page also serves as an overview of the files needed to create a module from scratch if you don't have access to run the command.

Pachno automatically autoloads any classes in your module from the namespace \pachno\modules\hello_world and follows the PSR-4 autoloading standard. This means your controllers live in \pachno\modules\hello_world\controllers and so on.

This is an overview of the default folders in your module. Some folder may or may not be present, but unless Pachno complains about a missing folder, there's no requirement to add it.

  • cli/ - contains any command line command classes you create. These classes lets you extend the pachno command line client, and any commands placed here are automatically available via the main bin/pachno client
  • components/ - contains the template files for the template components in your module
  • configuration/ - contains any custom configuration files you want to create.
  • controllers/ - contains all the controllers for your module. You decide if you want to create one or multiple controller(s). All controller classes present in this folder are automatically parsed for routes.
  • entities/ - folder for any custom database entities in your module as well as their corresponding table classes.
  • public/ - this folder contains any publicly available resources, such as javascript, css files or images.
  • templates/ - folder for all your route templates

In addition to some of the folders listed above, the following files should be present:

  • Components.php - This Components class extends \pachno\core\framework\ActionComponent and contains all components in your module.
  • Hello_world.php - This is the main module class for your module. This class should always be named the same as "module key with first letter uppercased" (in this case Hello_world) and extends \pachno\core\entities\Module - this class is where you define common behavior, place installation and uninstallation methods, listeners and other common methods for your module.
  • controllers/Main.php - This is the default controller class, which contains the routes for your module. You are free to create as many controller classes as you want, as long as they are placed in this directory.

Next steps

So far your module doesn't do anything, but it contains everything needed to be installed inside Pachno, ready to provide additional functionality. What you do next depends on what you want your module to do - run command line- or background tasks, create new pages or sections inside Pachno, extend or integrate with existing functionality, or a combination of it all.

The following are good starting points:

  • Creating new pages - if you want to create new pages, start here.
  • Creating background tasks - if you are looking to create background tasks or command line tasks, start here
  • Integrate with existing functionality - if you want to extend or override parts of Pachno, start here

Attachments 0

Comments 0

/unthemed/mono/no-comments.png
Expand, collaborate and share
Post a comment and get things done