Skip to content

Developer Guide Package Structure

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

Package structure and manifests

Developer Guide · First package · Lifecycle

Internals: Packages, ManifestReader, Dependency, Installation.

A package lives at awt_packages/<name-with-spaces-removed>/. The autoloader maps namespaces to paths under awt_src/classes/ first, then under awt_packages/; it throws when neither path exists. Use case-correct names and unique package namespaces such as DemoSite\services\Notifier in DemoSite/services/Notifier.php.

manifest.json and readable main.php are required by installation. Folder names such as controllers, routes, services, models and views are conventions, not required framework directories. Optional data/ files are copied to package public storage and registered. Optional install.php and update.php declare hook objects. The loader creates runtime objects from active database records; editing a manifest alone does not update installed metadata.

Manifest fields

Field Contract
name Nonempty string matching an alphanumeric first character followed by alphanumerics, spaces, underscores or hyphens. Spaces are removed for the executable folder path. Avoid names that collapse to the same directory.
version, minimum_awt_version Required version strings, one to three numeric components, optionally with a hyphen suffix.
maximum_awt_version Optional string or null; enforced as an upper bound during installation/startup.
type Required integer 0, 1 or 2. Startup creates runtimes only for nonzero types; there is no further distinct execution policy for 1 versus 2. Installation still requires main.php for type 0.
dependencies Required JSON list, even when empty; each item has name, optional version (default *) and optional url (default empty string).
author Validation allows omission/null, but the core database column is NOT NULL with no default. Supply a nonempty author to produce a usable install.
description, icon, preview_image, license, license_url Optional strings or null. Icon/preview paths can refer to files relative to data/; the installer converts matching registered storage entries to URLs.
system_package Optional bool or integer 0/1; system packages are enabled automatically. Ordinary new packages are disabled.

JSON may start with a UTF-8 BOM. Invalid JSON throws JsonException. Self-dependencies, duplicate dependency names and unsupported constraints are rejected. The reader returns the manifest array; repository persistence filters it to allowed fields.

Dependency constraints

Example excerpt replacing the first tutorial's empty dependency list:

"dependencies": [
  {"name": "MessageHub", "version": ">=1.0.0 <2.0.0", "url": ""}
]

Supported forms are *, exact versions and whitespace-separated comparisons joined by logical AND: >=, <=, >, <, =, ==, !=. Composer syntax such as ^1.0, ~1.0, 1.* and || is not supported. The url field is metadata; the dependency validator does not download packages automatically.

Install dependencies first. Installation checks existence/version; startup additionally rejects disabled dependencies, missing executable runtimes and cycles. A non-runtime type-0 dependency can satisfy manifest validation but cannot be an explicit runtime wait target. Runtimes explains that difference.

Keep untrusted filenames out of manifests, object-factory paths and schema definitions. These are trusted package author inputs and installing a package permits its PHP code to execute.

Clone this wiki locally