Seaside in PHP (Phaux)

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

ev0l
Forum Commoner
Posts: 56
Joined: Thu Jun 21, 2007 1:50 pm

Seaside in PHP (Phaux)

Post by ev0l »

Hi all,

I spent a number of years doing Smalltalk/Seaside development but I have done a number of large projects in PHP. One of the most interesting web frameworks I have seen or used in years is Seaside (http://seaside.st). One of it's greatest strengths, Smalltalk, puts it at a bit of a disadvantage. There are a whole lot more programmers that are comfortable with PHP and have neither the interest or fortitude to learn Smalltalk.

I decided to implement much of Seaside's functionality and more importantly style in PHP. It started out more as a proof of concept but ended up being very functional. While is lacks some of the "wow neato" features of Seaside (namely continuations) both Seaside's and Phaux's approach are similar.

I am looking for feedback on Phaux. The documentation is very sparse but there has been some discussion on the mailing list. I am mostly curious about what you all (PHP developers) think of the approach.

Check it out, use/abuse the code (it's under an MIT license), and have fun.

Thanks
Will
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

It sounds interesting, I'll take a look at it some time.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

A little example application would be helpful as there is a good amount of code there -- all named in a very un-PHP fashion. I am really not clear on the difference between callback and dispatch. My general comment after looking through the code is -- Ugh.
(#10850)
ev0l
Forum Commoner
Posts: 56
Joined: Thu Jun 21, 2007 1:50 pm

Post by ev0l »

A little example application would be helpful as there is a good amount of code there
Absolutely, I should of posted an example above. WHCounter is a very simple application that displays an number and allows the user to increment/deincrement a number with a click of a link. WHFormTest is an example of how Phaux handles forms.

Notice how in both examples url parameters are not specified. Phaux handles that for you and keeps your object completely encapsulated.
all named in a very un-PHP fashion
This is somewhat intentional I chose a more Smalltalk like style (as much as one can with a brackety language like PHP).
I am really not clear on the difference between callback and dispatch.
In this context neither am I :-)

In WHCounter notice

Code: Select all

$html->anchor()->callback($this,"add")->with("++")
That line creates an html anchor that when the user clicks on will call the method "add" on the $this object. You don't have to bother dealing with GET/POST vars or the other low level bits of http.
general comment after looking through the code is -- Ugh.
I am sorry to hear that. Phaux's biggest problem at the moment is lack of documentation. Phaux does things differently in compared to most (all?) PHP frameworks and because of this it is in desperate need of documentation. I tend to think the code a clean, well factored, and reasonable. But that is mostly because I wrote it :-).

If you don't mind I would ask you to browse through the Phaux-test directory and get another feel for Phaux. Give it a moment to sink in.

-Will

ev0l
Forum Commoner
Posts: 56
Joined: Thu Jun 21, 2007 1:50 pm

Another note on Phaux.

Post by ev0l »

One of the things I am trying to showcase is PHP5's (Phaux needs at least 5.2) object model. It is tremendously more powerful that PHP4's. In some ways more powerful than Java and C++ (PHP5 fully supports polymorphism). I did not want to inherent a PHP4 coding style in Phaux in an attempt to showcase the power of PHP5.

Now if PHP only had code blocks.

-Will
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you asking us to review your code?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I took a look at it and went through the base code. It looks like you spent a lot of time on it, but it definitely isn't my style.
ev0l
Forum Commoner
Posts: 56
Joined: Thu Jun 21, 2007 1:50 pm

Post by ev0l »

Are you asking us to review your code?
I was more looking for an exchange of ideas.
User avatar
kyberfabrikken
Forum Commoner
Posts: 84
Joined: Tue Jul 20, 2004 10:27 am

Post by kyberfabrikken »

Quite interesting. I don't like the base premise of a stateful framework - HTTP is stateless, and so should HTTP applications. I went through the google-group, and I noted that you mention that the statefulness of Phaux is the main feature, and that you haven't seen something like this in other frameworks for PHP. I don't have any working experience with PRADO, but isn't that exactly what it is about?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

kyberfabrikken wrote:Quite interesting. I don't like the base premise of a stateful framework - HTTP is stateless, and so should HTTP applications.
If you were to change your mind about that, much, much more powerful applications come to light.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

The code examples you've given are interesting, but unfortunately do nothing to wow me and look somewhat long-winded. It's a front-controller, all right, but what makes Phaux (which is a curious choice for a name as it's very close to "faux" (fault) in French) so powerful and great?
How does it do things differently to most frameworks? Statefulness is great, how is it handled - Sessions & DB?
Phaux website wrote:REServe object relational mapper provides automatic database table creation and migration. REServe and Phaux work together to provided rapid prototyping of web applications with no code generation.
That sounds like your trying to build a "press-this-button-to-build-your-application" framework - which I think you should be much clearer about.

To me, Phaux appears to try be too all-encompassing. When it comes to frameworks, it's a bit like cooking to me. I don't like the taste of ready-made meals, give me the right tools to cook a great meal and I would use allow me to improvise, create and play at every level - in short, a developer's minimalist framework. The golden example of this is still Voostind's Eclipse: http://sourceforge.net/projects/eclipselib/ It's a bit dated now (doesn't work with PHP5), but the concept behind it is exactly my taste & I like cooking with it. :)
User avatar
kyberfabrikken
Forum Commoner
Posts: 84
Joined: Tue Jul 20, 2004 10:27 am

Post by kyberfabrikken »

Jenk wrote:
kyberfabrikken wrote:Quite interesting. I don't like the base premise of a stateful framework - HTTP is stateless, and so should HTTP applications.
If you were to change your mind about that, much, much more powerful applications come to light.
I disagree.

Mind you, I realise that some things are better handled with server side state, but they are practical workarounds; I think it's a sane strategy to avoid server side state as far as possible. Using a framework which encourages the opposite is dangerous from my POV.
ev0l
Forum Commoner
Posts: 56
Joined: Thu Jun 21, 2007 1:50 pm

Post by ev0l »

kyberfabrikken wrote:Quite interesting. I don't like the base premise of a stateful framework - HTTP is stateless, and so should HTTP applications.
We don't write programs in Assembler because doing most things would be to much trouble. I don't have any problems with abstractions. On some level most web applications are stateful, persisting data in a database and managing session keys.
kyberfabrikken wrote: I went through the google-group, and I noted that you mention that the statefulness of Phaux is the main feature, and that you haven't seen something like this in other frameworks for PHP. I don't have any working experience with PRADO, but isn't that exactly what it is about?
PRADO uses templates. Phaux uses programatic code generation relying heavily on CSS for layout. PRODO's state must be handled explicitly by the programer. In Phaux state is implicit.
kyberfabrikken wrote: Mind you, I realise that some things are better handled with server side state, but they are practical workarounds; I think it's a sane strategy to avoid server side state as far as possible. Using a framework which encourages the opposite is dangerous from my POV.
"Dangerous"? Could you expand on that a bit more?

Maintaining state is something all web programmers spend a lot of time doing. Phaux just makes it much easier. Phaux, because of it's component architecture, also makes reusability much easier. Not explicitly dealing with GET/POST vars has some huge advantages. Check out WHNavigationTest. WHNavigationTest embeds the WHNavigation component and instructs the WHNavagation component to embed seven other components.

patrikG wrote: How does it do things differently to most frameworks? Statefulness is great, how is it handled - Sessions & DB?
Sessions. Larger applications would have to use something like tempfs to store the session data. The performance of large amounts of data in a session was one of the biggest surprises for me. PHP handles un/serializing faster than I expected.
patrikG wrote: That sounds like your trying to build a "press-this-button-to-build-your-application" framework - which I think you should be much clearer about
No in fact just the opposite. REServe allows you to treat a relational database like an object oriented one. REServe uses a follow reference approach to locating data not a relational one.

I built a number of classes that examine your object model and give you forms to handle that object model, similar to scaffolding but you can change just what you need. This is an area that needs some more work but the ideas are something I would like to explore further.
User avatar
kyberfabrikken
Forum Commoner
Posts: 84
Joined: Tue Jul 20, 2004 10:27 am

Post by kyberfabrikken »

ev0l wrote: We don't write programs in Assembler because doing most things would be to much trouble. I don't have any problems with abstractions. On some level most web applications are stateful, persisting data in a database and managing session keys.
That's not my point. It isn't the abstraction I find troubling. It's the strategy of storing application state at the server. I distinguish between two types of state: Application (session) state and Resource state. The former should - as far as practical - be stored at the client, and transferred with each request. The latter will be stored in the database, or what ever means of persistence, the application uses. By using this strategy, you gain a load of benefits.
ev0l wrote: PRODO's state must be handled explicitly by the programer. In Phaux state is implicit.
OK. I don't know PRADO that well, so I have (probably) wrongly assumed, that it worked implicitly.
kyberfabrikken wrote: Mind you, I realise that some things are better handled with server side state, but they are practical workarounds; I think it's a sane strategy to avoid server side state as far as possible. Using a framework which encourages the opposite is dangerous from my POV.
ev0l wrote: "Dangerous"? Could you expand on that a bit more?
Dangerous may be a strong word. I meant that if the framework encourages storing application state at the server, developers will make use of the feature, and consequently, the application will end up being stateful. As I explained, I think that makes for a weaker application.
ev0l
Forum Commoner
Posts: 56
Joined: Thu Jun 21, 2007 1:50 pm

Post by ev0l »

kyberfabrikken wrote:
Dangerous may be a strong word. I meant that if the framework encourages storing application state at the server, developers will make use of the feature, and consequently, the application will end up being stateful. As I explained, I think that makes for a weaker application.
Most stateful applications are load balanced by session. If you are worried about load balancing don't. It's very easy with a stateful application.

I am not sure what benefits you gain by not using a stateful framework. A stateful framework can do everything a RESTful or stateless framework can do but the same is not true in reverse at least not with a lot of difficulty. That is not to say Phaux and Seaside don't have disadvantages I just don't see how they are disadvantaged.
Post Reply