Download the PHP package drewlabs/mdl-cli without Composer
On this page you can find all versions of the php package drewlabs/mdl-cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drewlabs/mdl-cli
More information about drewlabs/mdl-cli
Files in drewlabs/mdl-cli
Package mdl-cli
Short Description PHP script for generating classes, interface, mixin, ect... based on UML model written in YAML or JSON language
License MIT
Informations about the package mdl-cli
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
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.
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 namemetadata
defines the project PSR-4 compatible namespace under which the components are generatedpath
: Thismetadata
defines the base path from whichOOP
component paths are generated.directories
: Thismetadata
isoptional
but help themdl-cli
to separateinterfaces
from core implementations and also provide directory formixins
which are PHPtrait
components.
-
OOP
components definitionOOP
components consist of actualclasses
,interfaces/contracts
andmixin/PHP Trait
objects generated for the given projects.OOP
components are grouped under:classes
: which consist of PHP or UML class componentsmixins
: which is not part of UML definition language but help in implementing theDRY
recommandation when developping software application. Basically, they consist of PHP traits components and are generated under the directory specify formixins
in the metada configuration.interfaces
: which contains the list ofinterfaces/contracts
that might be implemented in the given project.
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:
/mdl /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
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
Note The documentation is still under development and might change as API changes occur.