Download the PHP package maxi-format/maxi without Composer

On this page you can find all versions of the php package maxi-format/maxi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package maxi

maxi-php

PHP 8.0+ library for parsing and dumping MAXI schema + records.

Install

API overview

Method Description
Maxi::parse($input, $options) Parse MAXI text → MaxiParseResult (schema + raw records)
Maxi::stream($input, $options) Parse schema eagerly, yield records lazily via PHP generator
Maxi::parseAs($input, $classMap, $options) Parse + hydrate records into class instances
Maxi::parseAutoAs($input, $classes, $options) Same, with alias inferred from #[MaxiType] attributes
Maxi::dump($data, $options) Serialize objects / parse results → MAXI text
Maxi::dumpAuto($objects, $options) Same, with schema inferred from #[MaxiType]/#[MaxiField] attributes

All methods are also available as standalone functions in the Maxi\Api namespace (e.g. Maxi\Api\parseMaxi()).

Documentation

Quick start

Parse

Parse into class instances

Or with an explicit alias → class map:

Dump

Round-trip from a parse result:

From PHP objects with auto-detected schema:

With explicit type definitions:

Stream (lazy record parsing)

For large files, use streaming to avoid loading all records into memory at once. The schema is parsed eagerly; records are yielded one at a time via a PHP generator:

stream() also accepts a file handle (resource):

PHP Attributes — Doctrine-style annotations

Map MAXI types to PHP classes using native PHP 8 Attributes:

MaxiField supports the following options:

Option Type Description
typeExpr ?string MAXI type expression ('int', 'str[]', 'enum[a,b]', 'U')
annotation ?string Type annotation ('email', 'base64', 'hex')
required bool Adds the ! (required) constraint
id bool Marks this field as the record identifier
defaultValue mixed Default value when field is omitted
name ?string Override the serialized field name (defaults to property name)
constraints ?string Raw constraint string (e.g. '>=3,<=50')

Schema registry for third-party classes

For classes you don't own (no Attributes), register a schema descriptor manually:

Error handling

All parse/dump errors throw Maxi\Core\MaxiException which carries structured context:

Error codes

Code Name Description
E101 InvalidSyntaxError General syntax error
E102 DuplicateTypeError Duplicate type alias in schema
E103 UnknownDirectiveError Unrecognised @directive
E201 UnknownTypeError Record uses undefined type alias
E202 UndefinedParentError Parent type not defined
E203 CircularInheritanceError Circular type inheritance
E204 UnresolvedReferenceError Reference ID not found
E205 DuplicateIdentifierError Duplicate id in records
E301 ConstraintSyntaxError Malformed constraint
E302 InvalidConstraintValueError Invalid constraint value
E303 ConstraintViolationError Value violates a constraint
E304 ArraySyntaxError Malformed array literal
E401 SchemaMismatchError Too many/few values for type
E402 TypeMismatchError Value doesn't match field type
E403 MissingRequiredFieldError Required field is null/missing
E404 InvalidDefaultValueError Default value type mismatch
E405 UnsupportedBinaryFormatError Invalid bytes annotation
E501 EnumAliasError Duplicate or ambiguous enum alias
E601 UnsupportedVersionError @version value not supported
E602 SchemaLoadError Error loading external schema
E603 StreamError Error during streaming parse

Parser behavior options

By default, the parser warns on type mismatches, missing fields, and constraint violations instead of throwing. Tune this per option:

To make any of these fatal, set the relevant option to 'error':

External schema imports

MAXI files can import type definitions from external .mxs schema files. Provide a loadSchema callback to resolve them:

MAXI format (quick reference)

Test

License

Released under the MIT License.


All versions of maxi with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package maxi-format/maxi contains the following files

Loading the files please wait ...