SitePoint Sponsor |
|
User Tag List
View Poll Results: If you had a good PHP code generation tool would you use it?
- Voters
- 85. You may not vote on this poll
-
Of course, where can I download the source
22 25.88% -
Um, I would have to take a look at it
50 58.82% -
No, definitely not.
11 12.94% -
What's code generation?
2 2.35%
Results 26 to 49 of 49
Thread: Code Generation,
-
Nov 21, 2003, 12:07 #26
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by mlemos
PHP Code:class Contact {
getName() { }
getEmail() { }
}
Marcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Nov 21, 2003, 13:19 #27
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
...makes code generation more desirable
-
Nov 21, 2003, 13:58 #28
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by lastcraft
Keep in mind that Metastorage follows the JE WIN approach (Just Exactly What I Need), which means that it will only generate classes with the functions to manipulate your data objects that you require. For instance, if you do not need a function to delete an object, no code will be generated to implement such function. This is meant to make classes and lightweight as possible.
Currently, Metastorage does not generate automatic setters and getters functions. It may generate getters/setters functions for accessing class variables that store references to another objects (ie foreign keys).
So, if you would expect it to generate getters and setters for basic data types variables, that will be available if explicitly request it. The reason for this is that not everybody likes to bloat their classes with setters/getters functions. OTOH, without requesting setters/getters, the variables have to be made public and so in that case other features are disabled like lazy loading, automated persistence of only the variables that changed, etc..
Bottom line, is that you will get what you ask explicitly. The examples that come with Metastorage distribution may not show how to enable setters/getters but that does not mean they will not be supported.Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
-
Nov 21, 2003, 15:00 #29
- Join Date
- Feb 2003
- Location
- Virginia
- Posts
- 143
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I must say that it's incredibly helpful. The general process (briefly) is to create a project, add a db, add tables and fileds to that db, then generate forms for that db. The form fields have server side validation, calendar popups, file uploading and resizing (using ImageMagick) as well as saving file info to specified table. Finally add any extra components, like login (specifying which fields in what tables are used for username, password, etc).
Res
-
Nov 21, 2003, 17:50 #30
- Join Date
- Aug 2003
- Location
- Watford, UK
- Posts
- 62
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
I've only had a really quick look at this (Propel) so far, so I'm probably setting myself up for a pratfall here...
Originally Posted by lastcraft
. I've only had a scan thru the source/docs/files, but it looks from my glance that rather than using Torque as a persistence layer, it's a pretty direct port of Torque into PHP5. Having never looked at Torque myself I'm basing that assumption on the number of comments in the code that pop up with a (Torque) attribution, and those that refer to Java stuff. Maybe I'm just failing to see the crucial bit so far.
This idea of porting things almost directly from Java into PHP5 is intriguing, if a little odd. I guess it kind of maybe makes sense in avoiding reinventing the wheel...?
(btw, I don't know if this is why binary cloud is quiet, but Phing development is only PHP5 now too, maybe it'll be really loud when there's a release).
Interesting quote in their docs:
There are quite a number of object persistence layers for Java...however, there are very few solutions that even provide very basic o/r mapping for PHP. A few noteable:
* Metastorage - The only other comprehensive persistence layer for PHP [HL: that I know of]
(One last (entirely OT) thing, does anyone know of a tool to generate arbitrary amounts of random test data based on a SQL schema?)
Anyway, this is all interesting stuff, good luck with the project!
Cheers,
Jon
-
Nov 21, 2003, 18:37 #31
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi Manuel...
I had a ten minute look and it looks quite thorough...
Originally Posted by mlemos
.
Assuming I want getters, setters, lazy loading, etc (which I always do) is this definition correct for the example above?
Code:<class> <name>Contact</name> <variable><name>name</name><type>text</type></variable> <variable><name>email</name><type>text</type></variable> </class>
Some interim comments and questions...
1) I could do without the strict adherence to canonical XML. XML is verbose enough without making it any worse. What is wrong with a few attributes?
2) How do I inherit/use this storage class for domain objects? Apart from a single generated persist method there does not seem to be much control over exactly what gets written out. Do I just decorate that method? If I do, how do I tell the internal factories that I want my version, not the raw one?
3) How are transactions handled?
I would be very curious to know how you solved these issues.
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Nov 21, 2003, 18:53 #32
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by JonR
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Nov 21, 2003, 20:58 #33
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by lastcraft
Originally Posted by lastcraft
So, you will find that some things that you would like are not yet implemented, but if you would like them, you can always tell me what you think it should have.
Originally Posted by lastcraft
Originally Posted by lastcraft
Anyway, ideally you will use a more productive tool to edit your component definitions. I have a friend that told me that he will be working on a Dreamweaver template for Metastorage. Since I don't use Dreamweaver, I do not know how much more productive you can be with it.
In any case, component definitions are simple. You will not be editing them all the time to get so bothered with their verbosity.
Originally Posted by lastcraft
This is explained in Metastorage documentation but it will detailed in a simpler to understand way in the tutorial.html]Metastorage tutorial that is being written as we speak.
Basically, all objects are created by a factory class of which you need to create one instance per script/program. That applies to either objects being created from scratch or retrieved from storage. From than on, you just access the objects to do whatever you want and call a persist function to store the changes.[/font]
Originally Posted by lastcraft
If you need to customize any details, you do it in the component definition. If for some reason, you realize that the generated API does not satisfy any particular needs, you just need to tell me what you want so I can figure what can be done to address your needs consistently.
Originally Posted by lastcraft
Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
-
Nov 21, 2003, 22:17 #34
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by mlemos
I still don't know after your four posts in this thread. What does it do? I mean with an answer as a single example, not a verbal description. I don't want to get spammed by Yahoo just to find out. Do you not have other web space to place it on.
Originally Posted by mlemos
. I would formally add this as a feature request though, either as getName()/setName($name) or get("name")/set("name", $name).
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
.
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
. Do you know when you will be finished with the core functionality?
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Nov 22, 2003, 11:27 #35
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by lastcraft
Originally Posted by lastcraft
I already told you where the tutorial is available. The tutorial is in progress but is more than half done. I have even halted further development until I finish the tutorial document, which should happen in the next weeks.
Originally Posted by lastcraft
AFAIK Yahoo does not spam anybody that joins Yahoo Groups. Anyway, if you do not believe me, I have uploaded the tutorial as it is now to another site.
Originally Posted by lastcraft
Originally Posted by lastcraft
Originally Posted by lastcraft
I wanted to use tags with values that represented the macro names but I could not insert them in the schema if they were to be used in tag attributes. I would probably need to resort to a new markup language that does not clash with XML special characters. That would be awkward because XML is already the markup language itself. So, I moved all tag attributes to sub-tags before Metabase went public and never looked back.
Suggesting migration at a later stage is a bad idea. It just reflects that you lack of vision and planning. Usually you break bakwards compatibility and annoy everybody that is using your project. If you are doing this for a closed project that only envolves a few people, that may not be a big deal. But doing it in Open Source projects only makes people hate you for the lack of planning. Better safe than sorry.
Originally Posted by lastcraft
Originally Posted by lastcraft
Originally Posted by lastcraft
Originally Posted by lastcraft
Originally Posted by lastcraft
Originally Posted by lastcraft
This is not a commercial project that has to satisfy the needs of paying customers, so I do not need to lie to you and say it will be done soon. It is more likely that it will be done when I need each thing unless somebody else is willing to put up some work too.
Meanwhile, I suggest that you keep an eye in the Metastorage project progress and, if you want to help, just try what is available now and try to provide constructive feedback.Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
-
Nov 22, 2003, 15:30 #36
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Nov 22, 2003, 21:43 #37
- Join Date
- Aug 2000
- Location
- Bay Area, CA; (Pasadena, CA this fall)
- Posts
- 61
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi all,
The java->PHP translator I'm working on is going pretty well (but I decided to avoid issues with namespaces and inner classes and a few other issues).
Anyways, I'm including a persistence layer, which will be in the active style (because the translator is run every time you make a change to your java code; of course, you still run the translator...)
My goal was to make it easy for beginners to get going with the layer. Thus, there is no need to run an external program (like Torque's generator program).
Example Java:
Code:public class Member extends PersistableObject { StringProperty memberName=new StringProperty("name"); PrimaryKeyProperty id=new PrimaryKeyProperty(); //static Member _instance=null; //static ThingSet things=new ThingSet(); Composition moreData=new Composition(new MemberData()); Association possibleData=new Association(new PossibleData(),"fk2"); Aggregation items=new Aggregation(this,new Item()); /* (non-Javadoc) * @see persistent.PersistableObject#tableName() */ public String tableName() { return "members"; } }
BTW, I'm against functions like set($name) because if you have a typo when passing the name parameter then it's pretty painful. Once I became used to Java's strict-typing and numerous compiler checks, I've become very wary of checks that are only done at run-time (such as passing a string parameter representing the attribute).
I should also clarify that the intended audience is relatively new to web programming. I will probably not include transaction support (I've never seen the need for it myself yet because I only do fairly small projects).
So, this seems to be the approach that people would favor... I hope! Can anyone help me with the persistence layer? I'll release the relevant code if needed... (not sure yet if this will become open-source)
-
Nov 25, 2003, 17:20 #38
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by lastcraft
I have already wrote documentation with tens of kilobytes. Most of that documentation is not even useful to me because I wrote the project and so I know how it works without documentation.
The way you put it, it seems that I have to put your priorities over mine. The way I see it, if you decide to use the project, fine. I may even provide free support for you to develop whatever you want with Metastorage. If you decide to not use it, that is fine too. I try hard but I can't do miracles. I need to justify every minute that I spend developing this project, or else it means it is not being useful to me.
So, I think there must be good will in your part to move with the documentation that I already provide and do not ask me for doing something that I can hardly justify.
Originally Posted by lastcraft
I already tried to explain why it is the way it is. I can't justify the effort of changing it just because you are nit-picking.
If it is a big deal for you, I suggest that you design the XML format the way you want and and use XSL to transform it in a format that Metastorage takes.
Originally Posted by lastcraft
The way I want to make it work, is that you will be able to define your own event handler functions to be added to the generated data object classes if and when you want them. So, your component definition will include the code (in PHP) that will be used to fill in the event handlers that you need. See what I mean?
Originally Posted by lastcraft
Then I can tell you which I see more likely to be implemented first based on my needs for my current projects or eventually things that I may not need much but they are simple to implement and document.Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
-
Nov 25, 2003, 19:05 #39
- Join Date
- Jul 2000
- Location
- Perth Australia
- Posts
- 1,717
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Manuel , off topic but talking of Justification ....
Unfortunately the latest PHP versions have become a nightmare. Despite newer versions have fixed some old bugs, they also introduce new bugs in unsuspected places that break existing code.
Now that PHP is much more complex than it used to be, it is hard to determine where new bugs will affect the code of the site that has now over 50,000 lines of PHP source code. It seems to be safer to stay with old versions and deal with their bugs than to upgrade to a newer version and deal with surprise bugs.
.....
In any case, as much as the origin of the problem was in a PHP bug for which I am not responsible, I wish to apologize for this incident. I am working on better procedures to prevent that incidents like this will happen again. I will also keep improving the site avoiding as much as possible to make upgrades to unsafe newer PHP versions
-
Nov 25, 2003, 19:15 #40
- Join Date
- Apr 2003
- Location
- London
- Posts
- 2,423
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Hi...
Originally Posted by mlemos
If you can't handle feedback then don't post messages about the thing in the first place.
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
Originally Posted by mlemos
yours, MarcusMarcus Baker
Testing: SimpleTest, Cgreen, Fakemail
Other: Phemto dependency injector
Books: PHP in Action, 97 things
-
Nov 25, 2003, 19:43 #41
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by firepages
The site has daemon scripts that process the mail delivery queue one message at once. It is just a PHP script that gets called from cron every 15 minutes. New class notifications take more than 15 minutes because they go to many users.
When the delivery is started the script attempts to locks a flag file. If it succeeds, it is free to start a new delivery with the next message in the queue. Otherwise the script quits because there is a delivery in progress.
What was happening is that it was succeeding all the time. So the same message started being delivered many times.
Anyway, if you do not use flock or non-blocking locks, you should not be concerned with this. There are other serious bugs in other places though, especially in functions that deal client socket connections. Some of the problems I am trying to fix PHP itself once I have some time.Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
-
Nov 25, 2003, 20:47 #42
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by lastcraft
This means that it upsets me when have to stop to write explanations about things that you could learn by yourself if you have looked at the reference manual and the tutorial that is partly written but is already useful.
If you had an idea of how busy I am and how much I have to struggle to find time to write tutorials and other stuff that is meant mostly to make the project useful to others, you could understand why this upsets me.
Originally Posted by lastcraft
Originally Posted by lastcraft
Originally Posted by lastcraft
Originally Posted by lastcraft
Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
-
Nov 26, 2003, 03:48 #43
- Join Date
- Jul 2003
- Location
- Mainz, Germany
- Posts
- 119
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What I said is that making it useful to others is not my main goal for this project. This does not mean that I am not interested or do not value the feedback that others can provide.
This is/was a discussion about useful tools for code generation. If your tool does not fit that bill and is not intended to, then please don't tout it here. If you need help or feedback, ask for it on a thread of your own.Things that try to look like Things, sometimes
look more like Things than Things. - Granny Weatherwax
-
Nov 26, 2003, 09:49 #44
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by ZangBunny
When I say that it is not my main goal to make the project useful to others, I mean that I have to make it useful to use in my projects first, so my projects needs will have priority over other users requests. This does not mean that other user requests will not be satisfied. It is all a matter of priorities. I hope it is now clear for you.Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
-
Nov 28, 2003, 23:16 #45
Pbdo
One of the guys in our office has started a tool for our LogiCreate system called PBDO - PHP Business Data Objects. It's essentially a code generator which can take a Torque file and create PHP objects. It handles one->one and one->many relationships (I think many->many as well), cascading deletes, that sort of stuff. There's a clear separation in the generated code between what you can edit and what you can't. If you regenerate the base, your custom code won't be overwritten (though it may need to be tweaked).
You can download an earlier version of it from http://www.logicreate.com I know there's been some newer versions internally which aren't available for download yet, but that's just a time issue in posting. If anyone's interested in contributing, simply email us and we'll get you the files.
Also, you can get a somewhat newer version in the LogiCampus project on sourceforge.
I wrote in another post about this in another forum that it's tied to the LogiCreate platform's db layer. It's not all that hard to change it to generate code that works with something else, but that's just not been a priority for us at this point. If you'd like to contribute to that, feel free to pitch in.
For anyone interested, where we see LC going is being a dev framework *and* tools which complement each other and work together, rather than a disparate set of tools which are intended to be standalone (too many of those already, imo).
I'll answer theoretical questions about it, or help someone get it workin if you need that.
Thanks.Michael Kimsal
=============================
groovymag.com - for groovy/grails developers
jsmag.com - for javascript developers
-
May 26, 2005, 09:58 #46
- Join Date
- May 2005
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I want to let you know about my php code generation tool.
http://www.phpbackend.com/create_database.php
It generates forms and navigation menu given a database sql structure.
It includes html editors in text field on demand, big files transfert management with java applet (in the generated code), ordering system, and more important than anything: one-to many (or integrity constraints) management in mysql.
A postgresql version is almost done
Of course I want to evoluate my tool, and maybe later it will become more general purpose, and accept objects and uml as input.
I've been developping this for my clients projects and using it a lot. I got the idea that web backend could be generated by using field type and naming
However, I need some clients to have a reason to work more on it.
Any feedback is welcome
Nadine St-Amand
http://www.phpbackend.com
-
May 28, 2005, 15:21 #47
- Join Date
- Dec 2004
- Location
- Oakland, California
- Posts
- 784
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I use DB_DataObject (link) and I loooove it.
Jeffrey Hunt, freelance PHP & MySQL developer
Resume: http://www.jeffreyhunt.org/resume/
-
May 28, 2005, 15:55 #48
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by mlemos
Can you post a "hello world" style (code!) example?
DouglasHello World
-
Jun 6, 2005, 00:40 #49
- Join Date
- Apr 2002
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by DougBTX
Anyway, that tutorial was finished a long time a ago, so I removed it from that temporary site. You may find updated documentation including the tutorial here.
I don't know if that meets your expectations of a "hello world" example, but keep in mind that MetaL is one thing (a meta-language) and Metastorage (a persistent object classes generator) is an application of MetaL but you do not see any traces of MetaL when you use the result of Metastorage.
I admit this may seem confusing because all comes from the same site.Manuel Lemos
Metastorage - Data object relational mapping layer generator
PHP Classes - Free ready to use OOP components in PHP
Bookmarks