GithubHelp home page GithubHelp logo

customgen-php's Introduction

customgen-php (custom code generation for PHP based on Acceleo - Used in GenMyModel)

customgen-php is a UML to PHP generator written in Acceleo. This generator provides a way to generate your php classes from a UML class diagram.

For this first version, only the inheritance is managed.

Translation

Here is the mapping which is applied to UML in order to produce the PHP code.

UML PHP
Class (abstract or not) PHP class
Package folder (if the class is contents in the package, the PHP file will be created in the folder with the package name.)
Attribute Attribute of PHP class
Generalisation Inheritance between two classes
Model main.php

GenMyModel Integration

You can directly integrate this generator into GenMyModel using custom generators.

Clic on Tools then Custom generator. Add a custom gen and enter the following keys:

Generator name: PHPGEN (or whatever you want actually)
Github URL:     https://github.com/Axellience/customgen-php.git
Github branch:  master (not required)

As this generator is public on Github, there is no need to enter login information. Do not forget to save it and that's all. You are good to go! You can launch the generator and download the code source (zip format).

Technical Overview

This generator looks over the UML diagram and creates one php file per class. If the class is contained in a package, the php file will be created in the folder with the package name. Once the generator is in a class, if the class inherits from another, "extends" and "require" links will be generated. In the after step, the generator iterates on attributes and their visibility and add the code to a class. If the attribute visibility is set to "package", then it will be considered as protected.

Here is an example of generated code (from this UML model http://repository.genmymodel.com/ali.gourch/phpExample)

The hierarchy of generated files

|-- folder_1
|	|-- folder_2
|	|	|-- B.php
|	|-- A.php
|-- C.php
|-- D.php
|-- E.php

B.php

<?php
class B {
	protected $attribute_2;
	public $attribute_3;
	
}
?>

D.php

<?php
require_once 'folder_1/folder_2/B.php';

class D extends B {
	protected $attribute_4;
	
}
?>

E.php

<?php
require_once 'C.php';

class E extends C {
	public $attribute_5;
	
}
?>

Main.php

<?php
require_once 'D.php';

$D = new D();
$D->attribute_3 = "valueOfAttribute_3 \n";

echo $D->attribute_3;

?>

customgen-php's People

Contributors

gourch avatar tom1410 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.