Skip to content

Getting started

Chris Harrison edited this page Apr 22, 2021 · 4 revisions

Getting started

Install via composer

composer require chrisharrison/vo-generator

Add generated code folder to composer's autoload

Add the namespace and folder to composer.json.

{
  ...
  "autoload": {
    "psr-4": {
      ...
      "ValueObjects\\": ".vo.code/"
    }
  }
}

This puts all the generated value objects that get created in the .vo.code folder into the ValueObjects\ namespace.

Create some value objects

Create a file with the .voml extension anywhere in your project. (e.g. /value-objects.voml)

composite MaxArea {
  width: MaxWidth!
  height: MaxHeight!
}

Run

vendor/bin/vogen

The value objects will be created in the .vo.code folder and the classes will be available in the ValueObjects\ namespace.

You can read about how to define your value objects in VOML

Clone this wiki locally