MageWork

Back to home

Custom shared libraries

You can add custom libraries shared by all packages.

Add the classes in the lib directory from the project root. Create the lib directory if not exists.

Example

<?php
// lib/Tools.php

declare(strict_types=1);

class Tools
{
    public function format(string $value): string
    {
        return ucfirst(strtolower($value));
    }
}

You can then instantiate the class anywhere.

<?php

$tools = new Tools();

echo $tools->format('Hello World!');