This extension for StarUML(http://staruml.io) support to generate PHP code from UML model. Install this extension from Extension Manager of StarUML.
- Click the menu (
Tools > PHP > Generate Code...) - Select a base model (or package) that will be generated to PHP.
- Select a folder where generated PHP source files will be placed.
- Strict Mode (Type Hinting)
- Return Type (PHP7)
- PHPDoc
- Append to file extension
Belows are the rules to convert from UML model elements to PHP source codes.
- converted to PHP Package (as a folder).
- create namespaces
- converted to PHP Class. (as a optional separate
.class.phpfile) isAbstractproperty toabstractmodifier.isFinalSpecificationandisLeafproperty tofinalmodifier.- Default constructor is generated.
- All contained types (UMLClass, UMLInterface) are generated as inner type definition.
- Documentation property to PHPDoc comment.
- converted to PHP Field.
visibilityproperty to one of modifierspublic,protected,privateand none.nameproperty to field identifier.typeproperty to field type.multiplicityproperty to array type.isStaticproperty tostaticmodifier.isLeafproperty tofinalmodifier.defaultValueproperty to initial value.- Documentation property to PHPDoc comment.
- converted to PHP Methods.
visibilityproperty to one of modifierspublic,protected,privateand none.nameproperty to method identifier.isAbstractproperty toabstractmodifier.isStaticproperty tostaticmodifier.- UMLParameter to PHP Method Parameters.
- UMLParameter's name property to parameter identifier.
- UMLParameter's type property to type of parameter.
- UMLParameter with
direction=returnto return type of method. When no return parameter,voidis used. - UMLParameter with
isReadOnly=truetofinalmodifier of parameter. - Documentation property to PHPDoc comment.
- converted to PHP Interface. (as a separate
.interface.phpfile) visibilityproperty to one of modifierspublic,protected,privateand none.- Documentation property to PHPDoc comment.
- converted to PHP Field.
visibilityproperty to one of modifierspublic,protected,privateand none.nameproperty to field identifier.typeproperty to field type.- If
multiplicityis one of0..*,1..*,*, then collection type (Array) is used. defaultValueproperty to initial value.- Documentation property to PHPDoc comment.
- converted to PHP Extends (
extends). - Allowed only for UMLClass to UMLClass, and UMLInterface to UMLInterface.
- converted to PHP Implements (
implements). - Allowed only for UMLClass to UMLInterface.