Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » PHP-Java migration(Howto migrate a PHP project to Java with MoDisco)
icon5.gif  PHP-Java migration [message #550393] Fri, 30 July 2010 08:55 Go to next message
André B hlke is currently offline André B hlkeFriend
Messages: 14
Registered: July 2010
Junior Member
Hallo,

how would you migrate a PHP project to a Java project using MoDisco and other EMF based technologies? Is that Use-Case supported by MoDisco?

As far as I understand, I would take a PHP metamodel and transform it to a Java metamodel.

Thank you!

Kind regards,
André
Re: PHP-Java migration [message #550540 is a reply to message #550393] Fri, 30 July 2010 17:55 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi,

this use-case is not yet supported by MoDisco, since MoDisco does not
provide metamodels and discoverers dedicated to Php technology (such a
contribution would be welcome).

Yes, such a use case might be done, in some cases, with a transformation
from Php metamodel to Java metamodel. But it may require other metamodels :

PHP legacy agregates some Business logic (using php language) and some
UI logic (using html syntax & php language). It is convenient to
represent the two involved technologies with two metamodels. In Java
world, we may choose various corresponding technologies, e.g. JSP &
Java. So we may imagine a scenario like this :
-Discovery of PhpUI model and PhpScript model
-M2M -> IN : PhpUI model, PhpScript model OUT : Java model, JSP model
-M2T -> java and JSP files generation from Java & JSP models

Such a transformation is not easy to write, since the application
architecture may require some refactoring to fit with the target
platform --> it may be convenient to design it again at a more abstract
level, e.g. using a UML "PSM" representation. So a scenario of migration
may look like this :
-Discovery of PhpUI model and PhpScript model
-M2M -> IN : PhpUI model, PhpScript model OUT : UML model
-M2M -> INOUT : UML model
-M2T -> java and JSP files generation from UML model
-Completion of Java & JSP code (rewriting some operations in Java, ...)

Regards,
Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: PHP-Java migration [message #550556 is a reply to message #550540] Fri, 30 July 2010 19:13 Go to previous messageGo to next message
André B hlke is currently offline André B hlkeFriend
Messages: 14
Registered: July 2010
Junior Member
Hi Fabien,

thank you for the quick and resourceful response!

I think, it's hard to seperate a Php model into a PhpUI and a PhpScript model. That is one reason to leave the PHP world in the first place. PHP is a "Hypertext Preprocessor", which is -from time to time- accidently used to develop applications, sad as it is Sad I suppose, that's why PHP-to-Java migration is a common use case.

Modern PHP applications come with a MVC architecture. Let's say, we have a PHP MVC application. It might be possible to transform the Controller and the Model part to Java and to keep the View in PHP, using some kind of bridge, so the PHP views can still work.

What do you think about this:

1. normalize PHP code to fit into the Java model (refactor the use of "echo", global variables, put everything into classes, ...)
- M2M -> IN : PhpScript model OUT : PhpScript model

2. transform PHP model to Java model
- M2M -> IN : PhpScript model OUT : Java model, runtime configuration model (e.g. marking some classes as entry points)

3. M2T...
RESULT: Java Classes, PHP Views, runtime configuration
The result can run in a special runtime environment (PHP interpreter (100% Java), Servlets, ...)

Like that, you could build a half-automated way to make your PHP app business ready!

How would you start to build metamodels and discoverers for PHP? Are there resources, how to do that for interpreted languages? I could use some directions.

Thank you for the help!

Regards,

André
Re: PHP-Java migration [message #551144 is a reply to message #550556] Thu, 05 August 2010 11:28 Go to previous message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi,

keeping the views written in PHP will significantly reduce the work. I
don't know much about the related Java technical solutions.

"2. transform PHP model to Java model
- M2M -> IN : PhpScript model OUT : Java model, runtime configuration
model (e.g. marking some classes as entry points)"

Yes, such a step will fit the needs. It is necessary to have a mapping
between the common PHP libraries and the Java libraries (typically jre
libraries). We may think that a PHP/Java bridge (such as "PHP
interpreter 100% in Java") will already provide a java facade with PHP
common libraries api.

A way for building Metamodel and Discoverer for PHPScript is to have a
look at existing PHP development tools APIs, such as the eclipse project
PDT : such tools should provide syntaxic/lexical analysis to get an
Abstract Syntax Tree from the PHP script. Then, just as it was done for
the MoDisco Java Metamodel/discoverers reusing JDT, the metamodel
definition may be derivated from the AST structure, and the new
discoverer may reuse the syntaxic/lexical analysis feature to
instanciate model elements.
You may have a look at the Java discoverer
(plugins/trunk/org.eclipse.gmt.modisco.java.discoverer) from our SVN :
dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco

Modisco Java component wiki :
http://wiki.eclipse.org/MoDisco/Components/Java


At the moment, MoDisco roadmap focuses on JEE reverse but we are
interested in some contributions dealing with other technologies such as
PHP. A requirement for having such a contribution published into MoDisco
is not to have references to third libraries whose licences are not
EPL-friend.

Regards,
Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: PHP-Java migration [message #575511 is a reply to message #550540] Fri, 30 July 2010 19:13 Go to previous message
André B hlke is currently offline André B hlkeFriend
Messages: 14
Registered: July 2010
Junior Member
Hi Fabien,

thank you for the quick and resourceful response!

I think, it's hard to seperate a Php model into a PhpUI and a PhpScript model. That is one reason to leave the PHP world in the first place. PHP is a "Hypertext Preprocessor", which is -from time to time- accidently used to develop applications, sad as it is :( I suppose, that's why PHP-to-Java migration is a common use case.

Modern PHP applications come with a MVC architecture. Let's say, we have a PHP MVC application. It might be possible to transform the Controller and the Model part to Java and to keep the View in PHP, using some kind of bridge, so the PHP views can still work.

What do you think about this:

1. normalize PHP code to fit into the Java model (refactor the use of "echo", global variables, put everything into classes, ...)
- M2M -> IN : PhpScript model OUT : PhpScript model

2. transform PHP model to Java model
- M2M -> IN : PhpScript model OUT : Java model, runtime configuration model (e.g. marking some classes as entry points)

3. M2T...
RESULT: Java Classes, PHP Views, runtime configuration
The result can run in a special runtime environment (PHP interpreter (100% Java), Servlets, ...)

Like that, you could build a half-automated way to make your PHP app business ready!

How would you start to build metamodels and discoverers for PHP? Are there resources, how to do that for interpreted languages? I could use some directions.

Thank you for the help!

Regards,

André
Re: PHP-Java migration [message #575541 is a reply to message #550556] Thu, 05 August 2010 11:28 Go to previous message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi,

keeping the views written in PHP will significantly reduce the work. I
don't know much about the related Java technical solutions.

"2. transform PHP model to Java model
- M2M -> IN : PhpScript model OUT : Java model, runtime configuration
model (e.g. marking some classes as entry points)"

Yes, such a step will fit the needs. It is necessary to have a mapping
between the common PHP libraries and the Java libraries (typically jre
libraries). We may think that a PHP/Java bridge (such as "PHP
interpreter 100% in Java") will already provide a java facade with PHP
common libraries api.

A way for building Metamodel and Discoverer for PHPScript is to have a
look at existing PHP development tools APIs, such as the eclipse project
PDT : such tools should provide syntaxic/lexical analysis to get an
Abstract Syntax Tree from the PHP script. Then, just as it was done for
the MoDisco Java Metamodel/discoverers reusing JDT, the metamodel
definition may be derivated from the AST structure, and the new
discoverer may reuse the syntaxic/lexical analysis feature to
instanciate model elements.
You may have a look at the Java discoverer
(plugins/trunk/org.eclipse.gmt.modisco.java.discoverer) from our SVN :
dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco

Modisco Java component wiki :
http://wiki.eclipse.org/MoDisco/Components/Java


At the moment, MoDisco roadmap focuses on JEE reverse but we are
interested in some contributions dealing with other technologies such as
PHP. A requirement for having such a contribution published into MoDisco
is not to have references to third libraries whose licences are not
EPL-friend.

Regards,
Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Previous Topic:PHP-Java migration
Next Topic:Query Manager
Goto Forum:
  


Current Time: Sat Apr 20 01:17:13 GMT 2024

Powered by FUDForum. Page generated in 0.03607 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top