Skip to content

Autoloaders

Giuseppe Trivisano edited this page May 16, 2025 · 4 revisions

There are three autoloaders in this project that must be called at the beginning of the webhook file (hook.php):

  • vendor/autoload.php loads the Composer's libraries and all their classes
  • project_autoloader.php loads all the classes of the project except for the control/ classes
  • control/processes_autoloader.php loads the classes of processes, handled differently from the others

To make the project_autoloader.php work properly you must meet the PSR-4 standard.
These are the main rules:

  • for each new class created, the class name and the file name must be the same:
// inside Transaction.php file

class Transaction { ... }
  • the new classes must have the namespace definition like this:
// inside entities/banking/Transaction.php file

namespace CustomBotName\entities\banking;

class Transaction { ... }

The CustomBotName is the vendor namespace and should be modified, as explained in the installation section, before starting developing with the following command, putting your bot name in place of <HERE_YOUR_BOT_NAME>:

cd /path/to/project/
find . -type f -not -path ".git" -exec sed -i 's/CustomBotName/<HERE_YOUR_BOT_NAME>/g' {} \;

to be continued (explain the processes_autoloader.php)

Clone this wiki locally