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
- 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.
- 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
extends \pachno\core\framework\ActionComponentand 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
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.
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:
- - if you want to create new pages, start here.
- - if you are looking to create background tasks or command line tasks, start here
- - if you want to extend or override parts of Pachno, start here