Index

PackageManifest

MMO\core\helpers · 1 symbol · generated 30 Sep 2026

class

PackageManifest

PackageManifest.php:25

Store mmoframework package informations

class MMO\core\helpers\PackageManifest implements JsonSerializable
Namespace
MMO\core\helpers
Implements
JsonSerializable
Hooks: - include(this, $config): triggered by package manager when the manifest configuration is included - load(this): triggered when new data are loaded into the manifest - pre-build(this, filename, $options): triggered before building the package - post-build(this, filename, $options): triggered after building the package - package(this, filename, $options): triggered by the package manager when the package is copied to a project packages folder (the filename is the real package's filename) - i18n(this, $language, $file): triggered when internationalization file is loaded
$m = new PackageManifest(['name' => 'my-pkg', 'version' => '1.0.0', 'filename' => '/path/to/manifest.json']); $m->incVersion(); $m->save();

Index

bootstrap
build
demo
dependencies
description
documentations
filename
hooks
i18n
icon
included
keywords
languages
links
name
namespace
readme
sources
status
tests
title
urls
version
addHook($hook, $callback)Register a callback for $hook (see this class's own docblock for the list of hooks and when each fires).
build($filename, $compression, $options)Build package
debugName()
executeHook($name, $args)Execute a hook in the manifest
FromJsonFile($filename) static
getAllDependencies()
getBuildFilename()Get the package absolute filename
getBuildFolder()
getDemoFolder()
getDocumentationFolders()Get a list of existing documentations folders
getIconFilename()
getReadmeFilename()
getReleaseNotes()Get a list of releases notes filename
getShowcasePath($path)Resolve one of the showcase paths ($icon, $readme, $demo) against the manifest's folder.
getSkillFolders()The agent skills this package holds: every real folder of its .claude/skills/, which
getTestsFilename()
getTitle()
incVersion($where, $inc)Bump $version in place.
isPackageUpToDate()
isPhar()
isValid()Tells if manifest is valid
jsonSerialize()
load($data)Load data into the manifest
loadJsonFile($filename)Load (load) this manifest's data from a JSON file, also recording $filename itself ($filename).
loadLanguage($language)Load and register (with the shared I18n instance) this package's translations for $language, from
loopSources($resolve)
reload()Re-read this manifest's own $filename from disk, discarding any in-memory changes.
removeHook($hook, $callback)
save($filename)Write this manifest back out as JSON.
toArray()Get the manifest's data
__construct($data)

Properties23

bootstrap

string $bootstrap = 'src/bootstrap.php'
Type
string

build

string $build = 'build/{name}.{version}.phar'
Type
string

demo

string $demo = 'demo/www'
Type
string

dependencies

array $dependencies = []
Type
array

description

string $description = ''
Type
string

documentations

array $documentations = ['docs']
Type
array

filename

string $filename
Type
string

hooks

array $hooks = []
Type
array

i18n

string $i18n = 'src/i18n'
Type
string

icon

string $icon = 'icon.svg'
Type
string

included

bool $included = false
Type
bool

keywords

array $keywords = []
Type
array

languages

protected ?array $languages = null
Type
null | array

namespace

string $namespace
Type
string

readme

string $readme = 'README.md'
Type
string

sources

array $sources = ['src']
Type
array

status

string $status = 'stable'
Type
string

tests

string $tests = 'phpunit.xml'
Type
string

title

string $title = ''
Type
string

urls

array $urls = []
Type
array

version

string $version
Type
string

Methods31

addHook($hook, $callback)

PackageManifest.php:238

Register a callback for $hook (see this class's own docblock for the list of hooks and when each fires).

function addHook(string $hook, callable $callback): callable
$hookstring
$callbackcallablefunction(PackageManifest $manifest, mixed ...$args): void
returnscallable$callback, for chaining (e.g. $cb = $manifest->addHook(...), to later removeHook it)

build($filename, $compression, $options)

PackageManifest.php:333

Build package

function build( ?string $filename = null, int $compression = Phar::NONE, array $options = [] ): string
$filename = nullnull | stringthe filename for the package if null use the build key in the manifest
$compression = Phar::NONEintone of the PHAR compression constant
$options = []arrayforwarded to the 'pre-build'/'post-build' hooks
returnsstringthe package's filename

debugName()

PackageManifest.php:198
function debugName(): string
returnsstringe.g. 'my-pkg.1.0.0' NOTE: $name/$version are typed, non-nullable properties with no default, so a manifest that failed to load fully (e.g. an invalid config, see load) may not have them set yet. This is guarded with isset() because describe (used while rendering ANY exception whose $origin is this manifest, regardless of whether the message even mentions {origin}) calls debugName() unconditionally -- an unguarded access here used to turn a clear "unknown configuration" error into a confusing, unrelated "must not be accessed before initialization" one, masking the real problem.

executeHook($name, $args)

PackageManifest.php:266

Execute a hook in the manifest

function executeHook(string $name, mixed ...$args): bool
$namestringthe hook's name
...$argsmixed
returnsbooltrue if hook was executed
$manifest->executeHook('i18n', 'fr-FR', $file);

getDocumentationFolders()

PackageManifest.php:352

Get a list of existing documentations folders

function getDocumentationFolders(): array
returnsarray

getShowcasePath($path)

PackageManifest.php:401

Resolve one of the showcase paths ($icon, $readme, $demo) against the manifest's folder.

protected function getShowcasePath(string $path): ?stringNothing is ever created here: a package that ships no logo, no readme or no demo gets null, so whatever lists packages shows what is there instead of failing on what is not -- same contract as
See
getDocumentationFolders, which silently drops a folder that does not exist.
$pathstringa path relative to the manifest's folder, resolved through filename()
returnsnull | stringthe absolute filename, or null when $path is empty or names nothing

getSkillFolders()

PackageManifest.php:372

The agent skills this package holds: every real folder of its .claude/skills/, which

function getSkillFolders(): arrayA link is left out. Libraries link to the skill of the package that holds it (`mmoframework` is mmo.core's) rather than copying it, so following links would put that skill in every package.
See
MCPController serves and build puts in the package under the same name.
returnsarraystring> .claude/skills/<skill> => its folder
$manifest->getSkillFolders(); // ['.claude/skills/mmoframework' => '/…/libs/core/.claude/skills/mmoframework']

getTitle()

PackageManifest.php:386
function getTitle(): string
returnsstringthis package's human readable name, its short name when none was declared.

incVersion($where, $inc)

PackageManifest.php:172

Bump $version in place.

function incVersion(int $where = MMO\core\versions\PATCH, int $inc = 1): void
See
inc's own behavior)
$where = MMO\core\versions\PATCHintone of \MMO\core\versions\{MAJOR,MINOR,PATCH} -- only that single component is incremented, lower-precision components are NOT reset to 0 (see
$inc = 1int
returnsvoid
$manifest->incVersion(); // '1.0.0' -> '1.0.1'$manifest->incVersion(\MMO\core\versions\MINOR); // '1.0.1' -> '1.1.1' (patch is NOT reset)

isPackageUpToDate()

PackageManifest.php:311
function isPackageUpToDate(): bool
returnsbooltrue if the built package (getBuildFilename) exists and is newer than every source file (always true for a .phar package, which is inherently self-consistent)

load($data)

PackageManifest.php:208

Load data into the manifest

function load(array $data): void
$dataarrayevery key MUST be a declared public property of this class
returnsvoid
throwsif $data contains an unknown key

loadJsonFile($filename)

PackageManifest.php:129

Load (load) this manifest's data from a JSON file, also recording $filename itself ($filename).

function loadJsonFile(string $filename): self
$filenamestring
returnsself$this, for chaining

loadLanguage($language)

PackageManifest.php:463

Load and register (with the shared I18n instance) this package's translations for $language, from

function loadLanguage(string $language): bool
See
$i18n. Translation files are discovered (and cached) on first call; each is a plain PHP file returning a translation array, include_once-d so it only actually runs once even across repeated calls.
$languagestringa language tag (e.g. 'fr-FR'), matched via I18n::findLanguage (so a broader match like 'fr' can still resolve to a more specific 'fr-FR' file, or vice versa)
returnsbooltrue if a matching translation file was found (and loaded, or already had been)
$manifest->loadLanguage('fr-FR');

loopSources($resolve)

PackageManifest.php:300
function loopSources(bool $resolve = true): Generator
$resolve = trueboolif true, each source is resolved to an absolute path (relative to this manifest's own directory); if false, the raw $sources entries are yielded as-is
returnsGeneratorevery entry of $sources, skipping inline-code ones (those starting with '=')

removeHook($hook, $callback)

PackageManifest.php:249
function removeHook(string $hook, callable $callback): bool
$hookstring
$callbackcallablethe exact callback previously passed to addHook
returnsbooltrue if it was found (and removed)
$cb = $manifest->addHook('load', fn($m) => ...); $manifest->removeHook('load', $cb);

save($filename)

PackageManifest.php:153

Write this manifest back out as JSON.

function save(?string $filename = null): void
$filename = nullnull | stringdefaults to $filename; if given and $filename wasn't set yet, it is also adopted as this manifest's own filename
returnsvoid
throwsif $filename is null and $filename was never set