New PHP Framework

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

powerofq
Forum Newbie
Posts: 21
Joined: Thu Sep 11, 2008 1:51 pm
Location: Vancouver, BC

Re: New PHP Framework

Post by powerofq »

Hockey wrote:are you storing PHP code in the database and later eval'ing it?

I can't say I like that approach:
"In PHP, eval executes code in a string almost exactly as if it had been put in the file instead of the call to eval(). " -- Wikipedia
My IDE doesn't understand DB tables it understands native files
This framewerk has it's own online IDE.. no files means no files to manage, with the exception of images, pdfs etc. They are tagged, then stored in an Amazon S3 bucket.
Saying code and data are the same thing...I strongly disagree.
I simply meant PHP code IS data from a storage pov. Now there's different types of data, and there's different ways of handling it. That goes without saying.
How do you find the PHP source you are looking for if all source modules/functions/whatever are stored in a trivial lookup table?
With this framework everything is identified with a unique name (tag if you prefer.. whatever), that I call a subject. As you type the name of the subject into the IDE, all the relevant information pops up in the editor. The whole thing is online, and uses Codepress http://codepress.org/ as the editor.
Subject predicate and value fields to store an entire source tree sounds like a lot of work maintaining.
On the contrary. Manually maintaining this system is the easiest of any framework I've used for the reason stated above, in that everything is tagged. However, because the system is built as a semantic network (sorry) of nodes, arcs, isa's and hasparts, and was designed from the ground up as an AI tool, we can let the system handle the maintenance. Passing it a query like "Delete all animals" will remove Tweety from the system, as tweety isa canary. canary isa bird and bird isa animal.

When developing AI and natural language processing agents, one of the biggest problems you face is ambiguation. "Bob turned into a store" .. does this mean that Bob changed direction, or that he's a shape shifter, and morphed? To avoid this, we have ~bob~ (I use ~ to identify subjects.. not so much for humans, but more for the machine to parse), now we know what bob were talking about.. then we use the predicate .. something like "enteredbuilding" . No more ambiguation.. and this works well on all levels, including maintaing code.
powerofq
Forum Newbie
Posts: 21
Joined: Thu Sep 11, 2008 1:51 pm
Location: Vancouver, BC

Re: New PHP Framework

Post by powerofq »

matthijs wrote: However, is putting everything in one table not the concept of the OTLT or EAV?
I use the term EAV very loosley. A method to store triples would be a better definition.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: New PHP Framework

Post by josh »

Hmm, what I'm working on does something similar I guess but it uses XML to describe the semantic relationship between fields, and uses tables for each different "thing", by partitioning data I meant in terms of performance not semantics. Have you tested this with >10 million records in your table? What happens when you need to use for a high transaction application?

How do you handle relational data? Or do you use something more like the active record model? Have you examined the amount of traffic that gets exchanged between the web server and the database server? Just playing devils advocate here..
A database within a database... sounds fun all ready…
haha
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: New PHP Framework

Post by allspiritseve »

matthijs wrote:The terminology used here isn't very clear to me. However, is putting everything in one table not the concept of the OTLT or EAV? I recently did a bit of reading about it.

I soon found out there are some problems/considerations to deal with:
http://www.dbazine.com/ofinterest/oi-articles/celko22
http://tonyandrews.blogspot.com/2004/10 ... takes.html
http://decipherinfosys.wordpress.com/20 ... kup-table/
http://weblogs.sqlteam.com/davidm/articles/12117.aspx

I'm by far an expert on database design, so you should read those links for a good explanation
Those were an interesting read. I have been toying with the idea of an EAV for a while. My main reason for liking it was the global ID, so I could do associations between many different types. Have you had any experience with using global ID's with normal relational tables?
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: New PHP Framework

Post by matthijs »

Not so sure what you mean with global ID. But the main message I got out of those articles and from the people referring to them on other db forums was simple: don't use such a system.
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: New PHP Framework

Post by allspiritseve »

matthijs wrote:Not so sure what you mean with global ID. But the main message I got out of those articles and from the people referring to them on other db forums was simple: don't use such a system.
Yeah, that's why I found them interesting.

A global id is basically database-wide, instead of table-wide. So I could have an association table that handled associations between many different tables. It could be implemented in a normal relational database, if you update a global id table every time you insert a record into another table. If you had, for example, a blog post in a table "posts" with id "37", the global id table would have a record with id "104", that had a table field "posts" and id field "37". It's not quite as built-in as an EAV system, but the associations were really the biggest pull for me to such a system.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: New PHP Framework

Post by josh »

What associations does this allow you to make that you couldn't make otherwise? Did you consider using an existing ORM framework?
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: New PHP Framework

Post by allspiritseve »

Nothing you can't make otherwise-- but it would allow for general associations rather than explicit ones. If you have a lot of content tables, like pages, articles, FAQs, news items, blogs, photo galleries, etc., you couldn't add a photo gallery, an article, and a couple more pages to a given parent page without a page-to-photo gallery association table, a page-to-article association table, and a page-to-page association table. If you wanted to find all content that was a child of the given parent page, you'd have to query several tables.

With an association table that uses global ids, you could search the one association table, and find the global ids for every single item that has that page as a parent. Obviously it's much cleaner with an EAV, where the global id IS the content object id, but this would give global ids to normal relational tables. It's not something I've implemented-- just ideas I've tossed around for my homegrown CMS.
powerofq
Forum Newbie
Posts: 21
Joined: Thu Sep 11, 2008 1:51 pm
Location: Vancouver, BC

Re: New PHP Framework

Post by powerofq »

matthijs wrote:Not so sure what you mean with global ID. But the main message I got out of those articles and from the people referring to them on other db forums was simple: don't use such a system.
Forget EAV... instead think "Triplestore"
Here's a link to a Wikipedia article

http://en.wikipedia.org/wiki/Triplestore
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: New PHP Framework

Post by alex.barylski »

[quote="powerofq]Passing it a query like "Delete all animals" will remove Tweety from the system, as tweety isa canary. canary isa bird and bird isa animal.[/quote]

Does this apply to data or PHP objects as well?

While that is a cool idea in concept...I would argue that at the source code level this should be handled by advanced refactoring tools, if it's really needed.

Just curious...but how are is_a and has_a relationships expressed using the trivial table?
powerofq
Forum Newbie
Posts: 21
Joined: Thu Sep 11, 2008 1:51 pm
Location: Vancouver, BC

Re: New PHP Framework

Post by powerofq »

Although conceptually it's the same, the Framework trys to avoid the whole "Semantic Web" route, including RDF, OWL, SPARQL etc etc. It's not that it can't do these things, (because the data is stored as triples, I/O to and from XML is less than trivial) it's just once you go down that road, the average developer needs to commit to a rather nasty learning curve.

Maybe one day this will be the case, but I would argue we need the power of semantic networking today, and forcing developers to start using RDF is a game killer.
(Semantic web) An unrealized idea

The original 2001 Scientific American article by Berners-Lee described an expected evolution of the existing Web to a Semantic Web.[13] Such an evolution has yet to occur. Indeed, a more recent article from Berners-Lee and colleagues stated that: "This simple idea, however, remains largely unrealized."[14]
http://en.wikipedia.org/wiki/Semantic_Web
I believe this Framework solves this issue by simplifying the methods, and leaves room for RDF incorporation if and when the need arises.

Using the example at http://rockst-r.com/sandbox I linked to earlier.. when you add a bit of text, background, title, image..whatever.. you're actually creating Semantic Web content without even realizing it. Personally, I think this is the only way we'll get to a Semantic web as outlined by Berners-Lee.

And if nothing else, this Framework is at least based around that goal, and should be somewhat future proof. I'm unaware of any other PHP framework that emphasizes these things now, but would be interested in coming across one.
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: New PHP Framework

Post by allspiritseve »

powerofq wrote:Forget EAV... instead think "Triplestore"
I think of EAV as being a better, more normalized version of your "Triplestore".
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: New PHP Framework

Post by Christopher »

allspiritseve wrote:A global id is basically database-wide, instead of table-wide. So I could have an association table that handled associations between many different tables. It could be implemented in a normal relational database, if you update a global id table every time you insert a record into another table. If you had, for example, a blog post in a table "posts" with id "37", the global id table would have a record with id "104", that had a table field "posts" and id field "37". It's not quite as built-in as an EAV system, but the associations were really the biggest pull for me to such a system.
I think those are called foreign keys. ;)

Triplestores are almost always custom database engines, as I recall.
(#10850)
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: New PHP Framework

Post by allspiritseve »

arborint wrote:I think those are called foreign keys. ;)
I don't think you understand me. Foreign keys would be explicit associations.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: New PHP Framework

Post by alex.barylski »

I had a read of Semantic Web on Wikipedia...at least now I know what you mean by semantic web...

Sounds as though the problem you are trying to solve is one of the criticisms:
Another criticism of the semantic web is that it would be much more time-consuming to create and publish content because there would need to be two formats for one piece of data: one for human viewing and one for machines. However, many web applications in development are addressing this issue by creating a machine-readable format upon the publishing of data or the request of a machine for such data. The development of microformats has been one reaction to this kind of criticism.
I'm not sure why this couldn't be solved in any other CMS application framework. So long as data was stored in an intermediary format like (SQL, XML, etc) it could be generated dynamically based on user agent or something similar, no???

While I do agree with your goal I'm not sure the tool is exactly how I would solve the problem.

Also...I wouldn't describe what you have developed as a framework but more of a "Content Delivery Engine" and maybe append framework to that. A general purpose framework is what is typically assumed when you state you have designed a new framework...something along the lines of Zend or Cake.

I really like the idea of the embedded IDE (codepress is really neat -- thanks for the link) but I don't believe JS WYSIWYG editors are to the challenge just yet. I've worked on many commercial and open source WYSIWYG editors all of them had annoying quirks, mostly caused by virtue of being JS powered.

I like a structured file system as I find it simplifies my code. With everything stored in a global table I see potential for redundancy or misnomers.

For instance I can name two files "view.php" but their parent directories are what actually dictate their context and the name sets forth the purpose -- if that makes any sense.

If you only use the subject and/or predicate does this not limit you in the context depth?

Interesting idea though...you should certainly write some intro articles...comparing against known frameworks would be grand as well. It's tough to believe one framework is better than the next when neither are objectively compared.
Post Reply