Modeling tool for php

A PHP2UML model transformation for PHP reverse engineering

We propose a new model transformation process aiming at performing the reverse engineering of web-based PHP applications. Our PHP to UML approach follows an Architecture-driven Modernization (ADM) process. Model Transformation rules are expressed in ATL.

The first step was to find a way to parse the PHP code in order to extract the corresponding AST (Abstract Syntax Tree) model. In order to accomplish this task, we thought about using Modisco tool. As known, MoDisco is an Eclipse GMT project designed for the Model Discovery area. It is intended to facilitate the design and development of model-based solutions dedicated to legacy systems reverse engineering.

However, MoDisco only supports natively a few number of technologies. For instance, it does not offer any possibility to handle PHP web-based applications despite the importance of this language in the field of web development. So we have extended Modisco with PHP support. In particular, by benefitting from the open and extensible architecture of Modisco tool and respecting the OMG recommendations in terms of ADM, we built PHPDiscoverer, a new discoverer intended for PHP language. The model discovery process used by our PHPDiscoverer is illustrated in the following figure.

PHP Discoverery process

Fig. 1. The PHP Model discovery process

Concerning the PHP Specific ASTM, we used the Eclipse PHP Development Tools (PDT) library which allows the Eclipse IDE to assist the developers in editing PHP code by providing some features such as syntax highlighting, code auto-completion, syntax error detection, etc. This library contains a package of base classes called org.eclipse.php.core.ast.nodes , which our PHP Specific ASTM is based on. The following figure 2 gives an overview of these base classes organization. The ASTM is then saved in an Ecore file. This article gives more explanations about the PHP Discoverer realization steps.

Abstract Syntax Tree for PHP

Fig. 2.The PHP metamodel – Specific ASTM for PHP

The following example represents a simple PHP Math class contained in a PHP project, and that contains a static member with a function of adding two variables:

 class Math { public static final $PI = 3.14159265359; public function add($a, $b) { return $a + $b; } } ?>

By applying the model discovery process using the implemented PHP discoverer on the example shown above, we obtain the AST model (corresponding to the PHP Specific ASTM) serialized in XMI. This would be the XMI resulting from the “discovering” the previous PHP code.

 version="1.0" encoding="ASCII"?>  xmi:version="2.0" xmlns:xmi=http://www.omg.org/XMI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:php="http://eclipse.org/gmt/modisco/php/incubation/beta"> >  xsi:type="php:ClassDeclaration" modifier="none">  name="Math"/>  isCurly="true">  xsi:type="php:FieldsDeclaration" modifier="public static">  xsi:type="php:SingleFieldDeclaration">  xsi:type="php:Variable" isDollared="true">  xsi:type="php:Identifier" name="PI"/> >  xsi:type="php:Scalar" value="3.14159265359"/> > >  xsi:type="php:MethodDeclaration" modifier="public"> >  name="add"/>  isCurly="true">  xsi:type="php:ReturnStatement">  xsi:type="php:InfixExpression" operator="+">  xsi:type="php:Variable" isDollared="true">  xsi:type="php:Identifier" name="a"/> >  xsi:type="php:Variable" isDollared="true">  xsi:type="php:Identifier" name="b"/> > > > > >  xsi:type="php:Variable" isDollared="true">  xsi:type="php:Identifier" name="a"/> > > >  xsi:type="php:Variable" isDollared="true">  xsi:type="php:Identifier" name="b"/> > > > > > > > >

Next step is generating the UML model corresponding to this PHP AST model. To execute this mapping we defined a set of model-to-model transformations written in ATL, as depicted in the next figure.

The PHP to UML transformation process

Fig. 3. The php2uml model transformation process

As an example, you can see two of the transformation rules that initialize the UML model and generate a UML class for each PHP class declaration.

rule PHPAST2UMLModel < from a: PHP!AST to m: UML!Model( name collect(p | p.statement), ownedCommentcollect(p | p.comment) ) > rule PHPClassDeclaration2UMLClass < from p:PHP!ClassDeclaration to u:UML!Class( name select(o | o.oclIsTypeOf(PHP!FieldsDeclaration))-> collect(s | s.field), ownedOperationselect(o | o.oclIsTypeOf(PHP!MethodDeclaration)), generalization

Of course, here we have limited ourselves to these two examples, but there are many other transformation rules involved in this process.
By applying the set of ATL transformation rules on the AST model presented above, we obtain the corresponding UML model as shown below:

Generated UML class from the original PHP code

Fig 4. Generated UML class

For now the transformation focuses on the structural aspects of the PHP to UML transformation but we’re working on discovering also behavioural aspects and generating activity diagrams from them.

Источник

Создание UML по существующему PHP коду

Когда большинство проектов давно находятся на стадии поддержки, а не разработки, то поддержание документации в актуальном виде зачастую не проводится. Тогда довольно полезно будет получить диаграмму UML по существующему коду. Это также необходимо в случае, если предпроектная документация велась не полностью или проектированию подвергались не все части системы. Вопрос особенно актуален, когда появляется новый разработчик.

Консольный скрипт php2xmi

Интересной, на мой взгляд, реализацией механизма создания UML модели является консольный скрипт php2xmi, подробнее про который написано здесь.

  • Написан на PHP. Мы можем изменять его алгоритмы как захотим
  • Заявленная поддержка PHP Doc
  • Требует от наших проектов определённого правила подключения файлов
  • Не добавляет в модель исходный код для методов
  • Отсутствие постоянных обновлений

require_once ‘Zend/config.php’;
require_once ‘Zend/Config/ini.php’;
require_once ‘Zend/Config/xml.php’;
require_once ‘Zend/exception.php’;
require_once ‘Zend/Config/exception.php’;

* This source code was highlighted with Source Code Highlighter & me.

Для генерации моделей существующих проектов целиком можно добавить поддержку __autoload в этот скрипт.

Вывод: данный скприпт позволяет получить диаграмму существующих классов без дополнительных усилий. То, что он написан на PHP позволяет редактировать его любому разработчику по своему усмотрению.

Библиотека PHP_UML

Другой вариант создания UML диаграмм по существующему коду. Это также реализованный средствами PHP инструмент, но в отличие от предыдущего это уже библиотека для создания моделей. Ознакомление можно начать с просмотра примеров, которые входят в архив.

  • Поддержка XMI 2.1 – последняя версия данного стандарта. Одна из самых распространённых и качественных сред UML моделирования Umbrello также поддерживает эту версию.
  • Написан на PHP.
  • Удобная классовая структура.
  • Запускается как обычное web приложение
  • Читает PHP Doc
  • Не добавляет в модель исходный код методов

Вывод: по сравнению со скриптом php2xmi данный проект выглядит более профессионально выполненным, поэтому следует более пристальное внимание уделить его изучению.

Источник

Open Source PHP UML Tools for Linux

Browse free open source PHP UML Tools for Linux and projects below. Use the toggles on the left to filter open source PHP UML Tools for Linux by OS, license, language, programming language, and project status.

Product information management made simple with PIMworks PIMworks is a product experience management software that helps retailers and brands centrally manage product data.

Our PIM software helps you instantly syndicate your product data into multiple channels, quickly unify data from excel sheets and ERP systems into a centralized repository, and easily handle real-time workflows, enhancing the overall user experience.

Laboratory Information System CGM LABDAQ empowers labs of all sizes to optimize revenue and improve customer retention by increasing efficiency and streamlining workflow

CGM LABDAQ® from CompuGroup Medical is an advanced laboratory information system (LIS) that leverages a modern platform with decades of experience as the market-leading LIS.

Laravel MongoDB

This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. This library extends the original Laravel classes, so it uses exactly the same methods. Make sure you have the MongoDB PHP driver installed. In case your Laravel version does NOT autoload the packages, add the service provider to config/app.php. For usage with Lumen, add the service provider in bootstrap/app.php. In this file, you will also need to enable Eloquent. You must however ensure that your call to $app->withEloquent(); is below where you have registered the MongodbServiceProvider. The service provider will register a MongoDB database extension with the original database manager. There is no need to register additional facades or objects. When using MongoDB connections, Laravel will automatically provide you with the corresponding MongoDB objects.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

SuperModel is a PHP tool for defining data models at run time.

xtfer/supermodel

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

readme.md

SuperModel is a PHP tool for defining data models at run time.

Most data modelling tools for PHP are tightly coupled to the database APIs they are tied to. Others are rigid, and can’t be changed at runtime. SuperModel provides an API for defining a data model which is only generated when it is accessed. This allows the model to be altered, even during a request if necessary.

SuperModel makes no assumptions about your data source, storage, output or other components, and can be easily tied into other systems.

SuperModel assumes you will create a new Class to define your model that extends the SuperModel.

While SuperModel allows you to define things like whether a property is required, or changeable, it does not validate whether these properties are changed.

About

SuperModel is a PHP tool for defining data models at run time.

Источник

Читайте также:  Php get post head
Оцените статью