Metadata and generation
Posted: Fri Mar 31, 2006 1:54 pm
Are there any PHP apps that work with metadata without any code/html generation? For example, RoR uses database schema as metadata and generates HTML and code. I'm interested in this approach, but I despise code generation (unless it's run-time). So I tried to write my own class that would handle database interaction, HTML form generation, input validation, etc, using single source of metadata, which is coded in PHP.
It's quite difficul to conceptualize. So far I thought about creating Field class, and extending it to simulate various kinds of fields.
The code above would create an object, which represents text line. 1 is minimum length, 30 is maximim length, it must match given regExp, etc. In theory, this information could be used to create database field (varchar(30)), create html field (<input type="text" name="myname" maxlength="30" />) and to validate input.
The problem is that fields should be held in some kind of container. Let's call it Record. It's hard to decide what should be done inside Field, what should be done inside Record, and what whould be done somewhere else. So I want to look how existing application deal with such kind of things.
It's quite difficul to conceptualize. So far I thought about creating Field class, and extending it to simulate various kinds of fields.
Code: Select all
<? new Field_Line(1, 30, '/^[\w\d ]*$/'); ?>The problem is that fields should be held in some kind of container. Let's call it Record. It's hard to decide what should be done inside Field, what should be done inside Record, and what whould be done somewhere else. So I want to look how existing application deal with such kind of things.