PHPackages                             drewlabs/mdl-cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. drewlabs/mdl-cli

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

drewlabs/mdl-cli
================

PHP script for generating classes, interface, mixin, ect... based on UML model written in YAML or JSON language

v0.3.0(2y ago)1952MITPHPPHP &gt;=7.2

Since Mar 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/azandrew-sidoine/mdl)[ Packagist](https://packagist.org/packages/drewlabs/mdl-cli)[ RSS](/packages/drewlabs-mdl-cli/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (13)Used By (2)

mdl
===

[](#mdl)

MDL library is a php utility binary that internally uses `@drewlabs/code-generator` package to create project source code based on a textual UML definition language written in YAML, or JSON language.

MDL definition language
-----------------------

[](#mdl-definition-language)

The `mdl` definition language is a rapid `OOP Prototyping` tool that abstract aways `UML `design graphical tools though a `YAML `or `JSON `configuration file that is used by the client to generate source codes. Below is a basic example of `mdl` modeling language written in YAML.

```
name: 'Drewlabs\\MiaccSdk'
path: "/Users/azandrewsidoine/Workspace/azlabs/lib/php/mdl/src"
directories:
  interfaces: "Contracts"
  mixins: "Traits"

mixins:
  -
    name: "BaseTrait"
    methods:
      -
        name: "baseTraitMethod"

  - name: "MyTrait"
    mixins:
      - "Traits\\BaseTrait"
    methods:
      - name: "sayHello"
        comment: "Say Hello to application users" # optional
        returns: "void" # Optional
        modifier: "public" # Optional
        static: false # Optional
        parameters:
          - name: "name"
            type: string
            default: "PHP"
            optional: true
            variadic: false # Optional
            reference: false # Optional

interfaces:
  - name: "LoggerInterface"
    methods: # Optional
      - name: "log"
        comment: "Log to the console or the standard ouput"
        returns: "void"
        modifier: "public"
        parameters:
          - name: "args"
            default: "PHP"
            optional: false
            variadic: true # Optional
            reference: false # Optional
      -
        name: "baseTraitMethod"
  -
    name: "MyInterface"
    extends: "Contracts\\LoggerInterface"

classes:
  - name: "BaseClass"
    directory: "Core"
    abstract: true
    implements:
      - "Contracts\\LoggerInterface"
      - 'App\\ValueInterface'
  - name: "AbstractClass"
    abstract: true
    extends: "Core\\BaseClass"
  - name: "MyClass"
    final: true
    extends: "AbstractClass"
    constructor: true
    mixins:
      -
        "Traits\\DatabaseTrait"
    implements:
      - "Contracts\\TestInterface"
    setter: true
    immutable: true
    properties:
      - name: "console"
        comment: "Injected console object"
        type: 'App\\Console' # Optional
        modifier: "protected" # Optional
        readonly: false  # Optional
        # default: null # Optional
        # constant: false # Optional
    methods:
      - name: "__invoke"
        comment: "Used when the class is invoked as function" # Optional
        returns: "array" # Optional
        modifier: "public" # Optional
        static: false # Optional
        throws:
          - "\\RuntimeException"
```

The design language consist of two main parts:

- The project metadata definition As the name implies, the `project metadata` consist of metadata about the project for which the component are being generated. Below is the list of metadata properties that must be defined for a given project:

    - `name` : The name `metadata` defines the project PSR-4 compatible namespace under which the components are generated
    - `path`: This `metadata` defines the base path from which `OOP` component paths are generated.
    - `directories`: This `metadata` is `optional` but help the `mdl-cli` to separate `interfaces` from core implementations and also provide directory for `mixins` which are PHP `trait` components.
- `OOP` components definition `OOP` components consist of actual `classes`, `interfaces/contracts` and `mixin/PHP Trait` objects generated for the given projects. `OOP` components are grouped under:

    - `classes` : which consist of PHP or UML class components
    - `mixins`: which is not part of UML definition language but help in implementing the `DRY` recommandation when developping software application. Basically, they consist of PHP traits components and are generated under the directory specify for `mixins` in the metada configuration.
    - `interfaces`: which contains the list of `interfaces/contracts` that might be implemented in the given project.

The MDL CLI
-----------

[](#the-mdl-cli)

Once the definition language is written, we make use of the `mdl-cli` tool to generate the our project source code. The syntax for generating source code from `language defintion` file is:

> &lt;PATH\_TO\_BINARY\_DIR&gt;/mdl &lt;PATH\_TO\_LANGUAGE\_DEFINITION\_DIRECTORY&gt;/name.yml

For composer based project and assuming the language definition file is at the root of the project:

> ./vendor/bin/mdl $(pwd)/mdl.yml

### Command options

[](#command-options)

The `mdl-cli` command support options that allows developpers to change the behaviour of the command line client.

- settters

Setters are configured at class level in the configuration file. But to tell the `cli` tool to generate setters for all classes properties, we use the `--set` or `--setters` command line option.

> ./vendor/bin/mdl $(pwd)/mdl.yml --set

- getters

As with `setters`, `getters` are normally configured at class definition level. But we can also tell the `cli` tool to generate getter class for all classes in the generated code using `--get` or `getters` flag.

> ./vendor/bin/mdl $(pwd)/mdl.yml --get

- strict rule

PHP behave differently whenever the `declare_strict(...)` is added to a script file. By default, `cli` does not add this directive to the generated scripts. To tells the `cli` tool to add the required directive we use `--strict` flag in command line:

> ./vendor/bin/mdl $(pwd)/mdl.yml --get --strict

### Version 0.3.x changes

[](#version-03x-changes)

From version 0.3.x, the client support the following flags

- force

Force is added to allow users to bypass warning messages due to invalid configurations

> ./vendor/bin/mdl $(pwd)/mdl.yml --strict --force

- reflect &amp; reflection

Latest changes to the API allows application users to declare some classes are jsonnable, which uses PHP reflection API in `class::fromJson` implementation. This behavior is prevented by default due to the cost of using reflection API.

To add that behavior, the cli support a `--reflect` or `--reflection` class when running the cli.

> ./vendor/bin/mdl $(pwd)/mdl.yml --strict --reflection

**Note** Reflection can be enable or disabled at the class level by setting `reflection` property to `true` or `false`.

**Note** The documentation is still under development and might change as API changes occur.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~100 days

Total

12

Last Release

770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48c4973d500c7f4233d5ceacab51a57208d5fb60b0f95ae60264cf92380d0534?d=identicon)[azandrew-sidoine](/maintainers/azandrew-sidoine)

---

Top Contributors

[![azandrew-sidoine](https://avatars.githubusercontent.com/u/23530515?v=4)](https://github.com/azandrew-sidoine "azandrew-sidoine (22 commits)")

### Embed Badge

![Health badge](/badges/drewlabs-mdl-cli/health.svg)

```
[![Health](https://phpackages.com/badges/drewlabs-mdl-cli/health.svg)](https://phpackages.com/packages/drewlabs-mdl-cli)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
