Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: marzagao on January 22, 2003, 01:31:53 pm
-
Does anybody know if Enterprise Architect (or any other tool) will support reverse engineering and/or code generation of PHP classes?
Thanks.
-
The simnple answer is no.
However, Sparx have mentioned that a future version of EA will provide user-defined code templates. When this happens you can either define your own PHP templates or wait for someone else to.
Another possibility is to use the automation interface to write your own code generator.
I have used PHP to access the automation inetrface as a COM object. It is not too difficult to do this but requires a bit of digging about in the PHP and EA documentation.
I have pasted a "hello world" version of the code below.
Phil
<?php
$ea = new COM("EA.Repository") or die("Can't open EA");
$ea->OpenFile("C:\pathname to EA model...");
for ($m=0; $m<$ea->Models->Count; $m++){
$model=$ea->Models->GetAt($m);
echo "<h1>$model->Name</h1><br>";
for ($p=0; $p<$model->Packages->Count; $p++) {
$package=$model->Packages->GetAt($p);
echo "<h2>$package->Name</h2><br>";
for ($e=0; $e<$package->Elements->Count; $e++) {
$element=$package->Elements->GetAt($e);
echo "<h3>$element->Name</h3><br>";
}
}
}
$ea->Exit();
?>
-
Hey Phil,
Thanks for the quick reply. I guess I'll have to look for other tool as of now. :)