Configure programming language

Hello,

I’m evaluating VP Suite. As I mainly work for Open Sources projects in PHP, I started with Community Edition. But I just realized that PHP code generation requires Enterprise Edition. So I updated my key and configuration to Enterprise.

But if the code generation allows now the PHP, I still cannot select the PHP as being the programming language of the project.
Diagram Editor > right-click on project name > Configure Programming language… > Language drop-down listbox
I still have the choice of only: Java, XML Schema, C++, Visual Basic, C#, UML

Is that normal?

Cheers,
Guillaume

Hi Guillaume,

Actually, you need not to set the programming language to PHP in order to produce PHP code. The programming language setting is to help to make the modeling easier by allowing you to select the predefined type in Type drop down menu.

You just need to model your application using Class Diagram, and then generate PHP ORM code by selecting Tools > ORM > Generate Code from the main menu. Of course, remember to select PHP to be the code to generate.

Hope this helps. If you need more information, please feel free to let me know.

Best regards,
Jick

OK, but what about constructors/destructors?

In PHP4 the constructors are operations having the same name than their class name.
While in PHP5 those operations are named __construct and __destruct.

So, while modelling, I’m happy to decide if there will be a constructor (and/or a destructor) for the class and setting the number and types of parameters.
Well, of course I can re-type the name of the class, just hoping the PHP generator won’t add a prefix to the operation name.
But then, on the model, there is no visible difference between the constructor and other operations except by my knowledge of the programming language.
Isn’t there something to improve?

Cheers,
Guillaume

I understand now. I will ask our engineers if we can provide some PHP-specific functionalities.

Best regards,
Jick

Hi Guillaume,

Could you explain what did you mean by:
“I can re-type the name of the class, just hoping the PHP generator won’t add a prefix to the operation name” ?

Best regards,
Jick

[quote=Jick]Could you explain what did you mean by:
“I can re-type the name of the class, just hoping the PHP generator won’t add a prefix to the operation name” ?[/quote]

Ooops, sorry, I made a confusion with prefixes set for Attributes & Parameters.
But there is no prefix added on methods names.
Please forget my remark about this point.

Cheers,
Guillaume

Hi Guillaume,

Nevermind. Does this mean that you no longer have any problem with creating constructor and destructor?

Bset regards,
Jick

Hi Jick,

No, it only means that I noticed that operations names won’t change when generating the code.
But my demand for constructors/destructors is still active. :slight_smile:

As another example in PHP4 the name of the operation for the constructor is the same than the class itself. If in the model I change the name of the class, then I’ll have to be careful to change also the name of the constructor.
(which probably explains why in PHP5 they moved to call it “__construct”)

Another point for having ‘programming language’ set to PHP is to be able to define attributes/parameters types as ‘array’.
example: I want to setup an operation ReadRecord taking an array as parameter (tupple DBfield -> value) and returning an array (tupples DBfield -> value).
To do so I’ve typed in the Class box: -ReadRecord(RecordUniqueId : array) : array
But it’s not proposed as standard data type yet.

Cheers,
Guillaume

Hi Guillaume,

Thanks for your reply. I will discuss with our developers first.

Best regards,
Jick

Hi Guillaume,

Another point for having ‘programming language’ set to PHP is to be able to define attributes/parameters types as ‘array’.

To do so I’ve typed in the Class box: -ReadRecord(RecordUniqueId : array) : array

One question - Do you want to have an “array” type?

Best regards,
Jick

Regarding to the PHP language specificities, having the “array” as a type of data would be useful.
See http://php.net/manual/en/language.types.php for PHP data types.