PHP On Pie takes a fresh new approach.

19 points by EGreg ↗ HN
Hey everyone. I've been creating a "social application framework" called PHP On Pie over the past 2 years, mainly to streamline my own work with social media applications and also to re-use code and help my developers get up to speed quicker. I'm open sourcing it under the BSD license and hopefully others among you find it useful. If you do, feel free to contribute back to it.

I came up with its design after using a lot of other PHP frameworks, including Cake (RoR clone basically), symfony/agavi, CodeIgniter, Kohana and Zend. And drupal. I think PIE really tries to take advantage of the PHP way, and make things simple. If you want, you can drop classes from ZF or PEAR into it and they "just work". Anyway if anyone wants to get involved, drop me a line.

http://phponpie.com

26 comments

[ 4.6 ms ] story [ 75.5 ms ] thread
First thought: The opening tag line,

You can make great applications with PHP.

Is relatively underwhelming. It's like saying 'you can make great cakes with sugar.' - true, but not really saying a lot.

So many frameworks to choose from; why pick yours? Give me a single sentence mind-changer.
I would prefer to see something of more substance, like a feature comparison table with other frameworks.
Yeah I should put something there. I haven't thought of a single killer reason, except "it's faster, more powerful, takes advantage of PHP's unique strengths and encourages clean web programming"
IF you don't have something concrete, make something up that sounds concrete, within the realm of puffery.
Yeah, that's a good point. The site doesn't really sell the framework. Until now I haven't really devoted a lot of time to evangelizing it or anything. Beyond open sourcing it, I didn't really put in the time to grow a community around it.

What I wrote here is more of an early notice to the hackers out there who are interested in developing kick-ass applications in PHP. If you ask me -- and I've gone through a lot of frameworks -- this is definitely designed to help you achieve that with a minimum of fuss and a lot of power. I finished the documentation, but the sales job needs a lot more work. If anyone wants to contribute their time and energy to helping me grow this open source project, I'd much appreciate it. You would definitely have a huge role in the framework community if you did that. At the moment, though, I am more focused on my startup, and bringing developers on board to help with it. The documentation is there to help get them up to speed.

I must say, you've made a neat and clean website. Very inviting.

What would really get me to try it out is a video link on the first page. Just like the one on the play (Java) website. It should like play, show a jquery/ajax update. I've wanted to learn php (and a framework) for a long time, this could be it, if you give a short 10 minute demo.

The site is completely broken without javascript enabled.

You can't download the framework, you can't view the feature list, you can't click the "technology" tab.

None of those things require any particular functionality of javascript and could work as simple anchor tags.

Thanks, that's something I should fix. I don't think I'm using Javascript for anything other than the tabs + ajax. I'll convert them to regular anchors as a fallback.
What's up with the constant usage of compact()? Isn't it as icky and avoidable as its inverse, explode()?

Starting off the 'Technology' tab with supported OSes and servers couldn't be a good idea: those familiar with PHP will understand that incompatible with a system on which PHP is supported is a bug, but compatibility within PHP is obvious.

That said, the event system is interesting, and might be a good rethink of the Drupal hook system.

It's inverse is extract(). What's icky about using compact()?
Whenever reflection can be avoided, it should be. What makes it icky is that developers then need to worry about how they name their variables. It shouldn't be a problem so long there's a convention established.

Personally, when passing a lot of parameters, I condense them into a "Holder" class:

    $holder->var1 = "foo";
    $holder->var2 = "foo";
    //or set from array
    $holder->addArray(array("var1"=>"foo", "var2"=>"foo"));
    //later on, retrieving values
    $holder->useStrictMode(true); //optional: throws exception if key isn't present (rather than returning null)
    echo $holder->var1;
    echo $holder->var2;
    echo $holder->var3; //throws exception that var3 was expected to be present
It's worked well for me. It's also very handy for returning multiple values and status codes.
>What makes it icky is that developers then need to worry about how they name their variables.

Good point.

Because it's highly dependent on scope? Like, if I wanted to template each list item in an array, I could use array_map with another template function, but here I would have to keep re-assigning a variable in a foreach.

And it seems to be unclear on how you'd pass array and object members to it? It seems very much to encourage variable creep?

>if I wanted to template each list item in an array, I could use array_map with another template function

Good point.

I think you mean "extract", not "explode". And no, it's not icky. It's a very nice construct by PHP, to avoid having to write:

array ('foo' => $foo, 'bar' => $bar, ...)

and just write

compact('foo', 'bar')

what's wrong with that? :)

About the event system: Thanks man, I put a lot of effort into it. It's way faster than the drupal system, and also more extensible.

I want to see something significant built with the framework. That's what gets me to try something new.
Nicely done site, but I would say that immediately your site should tell what makes your framework stand out from the crowd.
At a quick glimpse at the framework code, I found several no gos for me: 1) First file i opened contained Methods with > 600 lines of code with mixed variable naming (camelcase and underscore). I don't want to debug that stuff, if I run into a framework bug. 2) Several classes/interfaces in a single file. What if I ie want to write my own adapters by using the given interfaces?

On the other side the code is very well commented (not all but most of it), which is a very huge plus.

Thanks for the feedback, but are you looking at the right framework? I am hard pressed to imagine how you could encounter either 1) or 2) in it, let alone both in a single file. As for your question, PIE is designed to let you write any adapters you want. For example it currently supports only MySQL, but you are free to add support for e.g. Postgres, SQLite or even NoSQL databases.

I'm just a bit surprised by your comments because they describe the exact opposite of how most of PIE is designed, and the philosophy behind it. Although I take your point with mixed variable naming. There is lots of room for standardizing the internal codebase more than it is.

framework/classes/pie.php 1082 lines long

Methods existing in the file: microtime, exceptionHandler, includeFile, autoload, var_dump, do_dump.

It's the first file I opened, and I see exactly what this guy saw immediately as well.

Right ... but I thought he said there were methods with > 600 lines of code, and files with multiple classes/interfaces all over the place. That's why I took issue with it. But yeah, the Pie class has all the core functions.
You have a typo on #10 - s/Competely/Completely/.
The site doesn't explain (anywhere that I could find) what is different about this framework, or what this "fresh new approach" is. That should be the first thing on the homepage.