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.php
file) isAbstract
property toabstract
modifier.isFinalSpecification
andisLeaf
property tofinal
modifier.- Default constructor is generated.
- All contained types (UMLClass, UMLInterface) are generated as inner type definition.
- Documentation property to PHPDoc comment.
- converted to PHP Field.
visibility
property to one of modifierspublic
,protected
,private
and none.name
property to field identifier.type
property to field type.multiplicity
property to array type.isStatic
property tostatic
modifier.isLeaf
property tofinal
modifier.defaultValue
property to initial value.- Documentation property to PHPDoc comment.
- converted to PHP Methods.
visibility
property to one of modifierspublic
,protected
,private
and none.name
property to method identifier.isAbstract
property toabstract
modifier.isStatic
property tostatic
modifier.- UMLParameter to PHP Method Parameters.
- UMLParameter's name property to parameter identifier.
- UMLParameter's type property to type of parameter.
- UMLParameter with
direction
=return
to return type of method. When no return parameter,void
is used. - UMLParameter with
isReadOnly
=true
tofinal
modifier of parameter. - Documentation property to PHPDoc comment.
- converted to PHP Interface. (as a separate
.interface.php
file) visibility
property to one of modifierspublic
,protected
,private
and none.- Documentation property to PHPDoc comment.
- converted to PHP Field.
visibility
property to one of modifierspublic
,protected
,private
and none.name
property to field identifier.type
property to field type.- If
multiplicity
is one of0..*
,1..*
,*
, then collection type (Array
) is used. defaultValue
property 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.