Helpers
You can create your own global "helper" PHP functions in designated directories, and Apiato will automatically autoload them for you.
Rules
- You MAY create as many helper files as you need per container.
- All container-specific helpers MUST be placed in the
app/Containers/{Section}/{Container}/Helpers
directory. - All general helpers MUST be placed in the
app/Ship/Helpers
directory.
Folder Structure
app
├── Containers
│ └── Section
│ └── Container
│ └── Helpers
│ ├── helpers.php
│ ├── mix.php
│ └── ...
└── Ship
└── Helpers
├── another-helper.php
├── and-another.php
└── ...
Code Example
if (!function_exists('add')) {
function add(int $firstNumber, int $secondNumber): int
{
return $firstNumber + $secondNumber;
}
}
Autoloading
Apiato is configured
to autoload all helper files in the app/Containers/{Section}/{Container}/Helpers
and app/Ship/Helpers
directories.
If the default configuration does not suit your needs, you can customize it via the Apiato Configuration class.