Index

PackageManager

MMO\core ยท 1 symbol ยท generated 30 Sep 2026

class

PackageManager

PackageManager.php:41
## Structure of the manifest: mmo.json the packages manager will try to find a mmo.json in the current folder or one of its parent in auto mode.class MMO\core\PackageManager extends MMO\core\classes\aModule
Namespace
MMO\core
Extends
aModule
(disable auto mode by setting a path in the manifest property or false) A manifest file is a json with the following information: - name: the library's name (ex: mmo.xxx) - namespace: the root namespace of the library (ex: MMO\xxx) - version: the library's current version (using semantic versioning specification (SemVer)) - dependencies: a map of library's name and version (ex: {"mmo.core": "20.0"}) - sources: (default [src]) a list of file and folder to add to the package - documentations: (default [docs]) a list of folder where the documentation is. You SHOULD have a folder releaseNotes inside one of this folder containing markdown files for the releases notes - bootstrap: (default src/bootstrap.php) the bootstrap file for the library - urls: [{name} => [{version} => {url}]] or [{folder}] - {url}: the manifest's url. - hooks: [{name} => {callback}] - {callback}: the function to call ## Hooks - pre-build: call before building the package. arguments: (manifest, filename). You can return a different manifest or null. - post-build: call after building the package. arguments: (manifest, filename). No return expected. - package: call when a project is built into a package - load: called by the package manifest itself when it loads its data

Index

compression
discoverFolders
manifests
manifestUrls
packagesFolder
phar
project
projectManifest
urls
addUrl($name, $version, $url)Register one more place a package's manifest can be found (readManifest discovers these automatically from a manifest's own urls entry).
buildDependencies($dependencies, $folder, $name, $version, $options)Build all dependencies linked to a package
buildProject($manifest, $additionalPackages, $folder, $options)Build a project from a manifest
DefaultConfig() static
discoverUrls($folder, $depth)Discover url reading package*.phar and mmo.json
enablePhar($value)Enable phar packages
fetchBuild($filename, $name, $version, $options)Fetch a package or build it in the manifest folder and copy it to the destination
getCompression()
getDependencies($name, $version, $packageVersions)Get the dependencies needed for a package
getManifest($name, $version)Get a manifest by name and version
getManifestByNamespace($ns, $version, $included)
getManifests()
getProject()
getProjectBuildFolder($manifest)
getProjectManifest()
getUrl($name, $version)
getUrls()
hasUrl($name)
inc($name, $version)Include a package and every one of its (not-yet-included) dependencies, in dependency order: requires each one's bootstrap file and merges its returned configuration (mergeIโ€ฆ
includedVersion($name, $versionConstraint)
incVersion($manifest, $where, $inc, $save)Increment manifest version and update indexes
isIncluded($name, $versionConstraint)
isPharEnabled()
loopIncluded()
loopManifestByNamespace($ns, $version, $included)
loopManifestByVersions($name, $versionConstraint)Tells if a manifest exists and returns its version
readManifest($url)Read manifest and trigger manifest-read hook
setCompression($compression)
setProject($url)Set the main manifest (mmo.json) to load for the project
__construct($config)Includes this framework's own package (mmo.core), then discovers sibling .phar packages if running from one itself.

Properties9

compression

protected int $compression = 0
Type
int

discoverFolders

#[MMO\core\attributes\Serialize(false)] protected array $discoverFolders = []
Type
array

manifests

#[MMO\core\attributes\Serialize(false)] protected array $manifests = []
Type
array

manifestUrls

#[MMO\core\attributes\Serialize(false)] protected array $manifestUrls = []
Type
array

packagesFolder

protected string $packagesFolder = 'packages'
Type
string

phar

protected bool $phar = true
Type
bool

project

#[MMO\core\attributes\Serialize(unserialize: 'setProject', order: 10)] protected ?string $project = null
Type
null | string

projectManifest

#[MMO\core\attributes\Serialize(false)] protected ?MMO\core\helpers\PackageManifest $projectManifest = null
Type
null | PackageManifest

urls

#[MMO\core\attributes\Serialize(false)] protected array $urls = []
Type
array

Methods30

addUrl($name, $version, $url)

PackageManager.php:211

Register one more place a package's manifest can be found (readManifest discovers these automatically from a manifest's own urls entry).

function addUrl(string $name, string $version, string $url): void
$namestring
$versionstring
$urlstring
returnsvoid

buildDependencies($dependencies, $folder, $name, $version, $options)

PackageManager.php:615

Build all dependencies linked to a package

protected function buildDependencies( array &$dependencies, string $folder, string $name, string $version = '*', array &$options = [] ): void
$dependenciesarray
$folderstringthe folder to build the phar into (MUST end with '/')
$namestringthe name of the package
$version = '*'stringthe version to build
$options = []arrayoptions passed to the package's hook and used to determine if a package needs to be built * if a package's namespace is a key, the boolean associated value force/prevent the build of the package * ex: $options['MMO\\core'] = false will prevent package mmo.core to be built
returnsvoid

buildProject($manifest, $additionalPackages, $folder, $options)

PackageManager.php:641

Build a project from a manifest

function buildProject( MMO\core\helpers\PackageManifest|string $manifest, array $additionalPackages = [], ?string $folder = null, array &$options = [] ): array
$manifestPackageManifest | stringif string, the filename of the manifest (eq: mmo.json)
$additionalPackages = []arraypackages to add to the project, same format as \MMO\inc(): [package => version, ...] or [package, ...] (version defaults to '*', the latest)
$folder = nullnull | stringthe folder to build the packages into (if null use manifest folder ./packages )
$options = []arrayoptions to pass to the hook of each packages (WARNING: passed by reference)
returnsarraythe list of packages and version built

DefaultConfig()

staticPackageManager.php:72
static function DefaultConfig(): array
returnsarraydefault configuration: $project is auto-detected by walking up from the running script's directory looking for an mmo.json (null if none is found up to the filesystem root).

discoverUrls($folder, $depth)

PackageManager.php:180

Discover url reading package*.phar and mmo.json

function discoverUrls(string $folder, int $depth = 1): self
$folderstringa valid local folder
$depth = 1intthe depth to look for in folder (default 1, direct manifest only). set to -1 to walk through every child folder
returnsself

fetchBuild($filename, $name, $version, $options)

PackageManager.php:573

Fetch a package or build it in the manifest folder and copy it to the destination

function fetchBuild( string $filename, string $name, string $version = '*', array &$options = [] ): string
$filenamestringthe destination for the package
$namestringthe package's name
$version = '*'stringthe package's version
$options = []arrayoptions passed to the package's hook and used to determine if a package needs to be built if a package's namespace is a key, the boolean associated value force/prevent the build of the package ex: $options['MMO\\core'] = false will prevent package mmo.core to be built
returnsstringthe version fetched

getCompression()

PackageManager.php:117
function getCompression(): int
returnsintthe compression mode used when building .phar packages (a \Phar::* constant, e.g. \Phar::NONE/\Phar::GZ).

getDependencies($name, $version, $packageVersions)

PackageManager.php:439

Get the dependencies needed for a package

function getDependencies(string $name, string $version = '*', array $packageVersions = []): array
$namestring
$version = '*'string
$packageVersions = []arraythe versions of packages to prioritize
returnsarray

getUrl($name, $version)

PackageManager.php:226
function getUrl(string $name, string $version = '*'): array
$namestring
$version = '*'stringa version constraint (loopVersions).
returnsarrayevery URL registered for a version of $name matching $version, most recent matching version first.
throwsif $name is entirely unknown.

getUrls()

PackageManager.php:206
function getUrls(): array
returnsarrayname => [version => [url, ...]] every known manifest URL, whether or not its manifest has actually been read yet.

inc($name, $version)

PackageManager.php:485

Include a package and every one of its (not-yet-included) dependencies, in dependency order: requires each one's bootstrap file and merges its returned configuration (mergeInject) into the shared Configuration, unless an Inc listener stops the event for it.

function inc(string $name, string $version = '*'): void
$namestring
$version = '*'stringa version constraint.
returnsvoid
throwsif $name (or one of its dependencies) can't be found.
throwsif an included package's folder can't be resolved (not a phar, not a local directory).

includedVersion($name, $versionConstraint)

PackageManager.php:408
function includedVersion(string $name, string $versionConstraint = '*'): ?string
$namestring
$versionConstraint = '*'string
returnsnull | stringthe version of $name currently included (inc), matching $versionConstraint, or null if none is.

incVersion($manifest, $where, $inc, $save)

PackageManager.php:540

Increment manifest version and update indexes

function incVersion( MMO\core\helpers\PackageManifest $manifest, int $where = MMO\core\versions\PATCH, int $inc = 1, bool $save = true ): string
$manifestPackageManifest
$where = MMO\core\versions\PATCHint
$inc = 1int
$save = truebool
returnsstringthe new version

isIncluded($name, $versionConstraint)

PackageManager.php:416
function isIncluded(string $name, string $versionConstraint = '*'): bool
$namestring
$versionConstraint = '*'string
returnsboolwhether a version of $name matching $versionConstraint is currently included (inc).

isPharEnabled()

PackageManager.php:129
function isPharEnabled(): bool
returnsboolwhether .phar packages can be loaded (enablePhar) -- defaults to true outside dev mode, or when this project itself runs from a phar.

loopManifestByNamespace($ns, $version, $included)

PackageManager.php:377
function loopManifestByNamespace(string $ns, ?string $version = null, ?bool $included = null): Generator
$nsstringa namespace prefix, e.g. 'MMO\core' (also matches sub-namespaces, e.g. 'MMO\core\server').
$version = nullnull | stringa version constraint, if only specific versions should match.
$included = nullnull | boolif given, only match manifests that are (or aren't) currently included (isIncluded).
returnsGeneratorevery matching manifest.

loopManifestByVersions($name, $versionConstraint)

PackageManager.php:328

Tells if a manifest exists and returns its version

function loopManifestByVersions(string $name, string $versionConstraint = '*'): Generator
$namestring
$versionConstraint = '*'stringa constraint on the version to look for
returnsGenerator($version => $manifest), most recent matching version first, among already-read manifests only (readManifest -- doesn't discover new ones).

setCompression($compression)

PackageManager.php:122
function setCompression(int $compression): bool
$compressionint
returnsboolwhether the compression mode actually changed.

setProject($url)

PackageManager.php:149

Set the main manifest (mmo.json) to load for the project

function setProject(?string $url): void
$urlnull | stringa valid mmo.json (can be inside a phar)
returnsvoid

__construct($config)

PackageManager.php:98

Includes this framework's own package (mmo.core), then discovers sibling .phar packages if running from one itself.

protected function __construct(array &$config)
$configarray
Inherited members (46)
ConstantsDeclared byDescription
ALERTiLogLevelAlert: Action must be taken immediately.
ALLiLogLevelMask for all
ALL_PLUSiLogLeveldebug everything
BACKTRACEiLogLevel
CRITICALiLogLevelCritical: Critical conditions.
DEBUGiLogLevelDebug: Detailed debug information.
DEEPiLogLeveldebug everything with arguments
EMERGENCYiLogLevelEmergency: System is unusable.
ERRORiLogLevelError: Runtime errors that do not require immediate action but should typically be logged and monitored.
ERROR_PLUSiLogLevelMask for all error
FATALiLogLevelMask for all fatal error
INFOiLogLevelInfo: Interesting events.
INFO_PLUSiLogLevelMask for all errors/warning/notices/info
MEMORYiLogLevelinclude backtrace object
NOTICEiLogLevelNotice: Normal but significant events.
NOTICE_PLUSiLogLevelMask for all errors/warning/notices/info
TRACEiLogLevelinclude backtrace as origins
WARNINGiLogLevelWarning: Exceptional occurrences that are not errors.
WARNING_PLUSiLogLevelMask for all errors and warnings
PropertiesDeclared byDescription
verbosityaModule
MethodsDeclared byDescription
alert($message, $context)aModuleAction must be taken immediately.
backtraces($message, $context)aModuleForce-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).
Configure($config)aModuleMerge $config into this module's configuration in the shared Configuration.
critical($message, $context)aModuleCritical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)aModuleDetailed debug information.
debugName()aModuleHuman-readable identifier used as the default {origin} in this instance's log messages.
emergency($message, $context)aModuleSystem is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
error($message, $context)aModuleRuntime errors that do not require immediate action but should typically be logged and monitored.
getVerbosity()aModule
info($message, $context)aModuleInteresting events. No-op if INFO is currently filtered out by the verbosity mask.
Instantiate($config)aModule(Re)create the shared instance immediately, configured with $config merged into the class's existing config.
IsShared()aModule
log($level, $message, $context)aModuleLogs with an arbitrary level.
notice($message, $context)aModuleNormal but significant events.
offsetExists($key)aModule\ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access.
offsetGet($key)aModule\ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g.
offsetSet($key, $value)aModule\ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g.
offsetUnset($key)aModule\ArrayAccess::offsetUnset -- equivalent to $module[$key] = null.
serialize($path, $serializer)aModule\MMO\core\interfaces\iSerializable::serialize -- exports every property (via
setVerbosity($verb)aModuleSet the current verbosity mask, replacing whatever it was before.
Shared()aModuleGet the shared instance, creating (and configuring) it on first call.
testVerbosity($level)aModuleTest whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
traitUnshare($serialize)aModuleRemove the shared instance, so the next Shared() call creates a fresh one.
unserialize($data, $path, $instances)aModule\MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via
Unshare($serialize)aModuleLike tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it.
warning($message, $context)aModuleExceptional occurrences that are not errors.