News for hackers. Stuff that matters.

PHP On Pie takes a fresh new approach.

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 | 19 points | on HN )
Re:PHP On Pie takes a fresh new approach. by Qz on Sunday September 12, 2010 @01:07AM (#1683085)
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.

Re:PHP On Pie takes a fresh new approach. by pruhstal on Sunday September 12, 2010 @01:23AM (#1683112)
So many frameworks to choose from; why pick yours? Give me a single sentence mind-changer.
Re:PHP On Pie takes a fresh new approach. by MC27 on Sunday September 12, 2010 @08:27AM (#1683533)
I would prefer to see something of more substance, like a feature comparison table with other frameworks.
Re:PHP On Pie takes a fresh new approach. by EGreg on Sunday September 12, 2010 @10:06PM (#1685215)
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"
Re:PHP On Pie takes a fresh new approach. by Qz on Monday September 13, 2010 @03:24PM (#1687861)
IF you don't have something concrete, make something up that sounds concrete, within the realm of puffery.
Re:PHP On Pie takes a fresh new approach. by EGreg on Sunday September 12, 2010 @10:03PM (#1685211)
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.

Re:PHP On Pie takes a fresh new approach. by tmcw on Sunday September 12, 2010 @01:40AM (#1683138)
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.

Re:PHP On Pie takes a fresh new approach. by mcantelon on Sunday September 12, 2010 @02:28AM (#1683182)
It's inverse is extract(). What's icky about using compact()?
Re:PHP On Pie takes a fresh new approach. by photon_off on Sunday September 12, 2010 @04:28AM (#1683305)
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.
Re:PHP On Pie takes a fresh new approach. by mcantelon on Sunday September 12, 2010 @05:26PM (#1684592)
>What makes it icky is that developers then need to worry about how they name their variables.

Good point.

Re:PHP On Pie takes a fresh new approach. by tmcw on Sunday September 12, 2010 @11:42AM (#1683810)
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?

Re:PHP On Pie takes a fresh new approach. by mcantelon on Sunday September 12, 2010 @05:28PM (#1684594)
>if I wanted to template each list item in an array, I could use array_map with another template function

Good point.

Re:PHP On Pie takes a fresh new approach. by EGreg on Sunday September 12, 2010 @10:04PM (#1685214)
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.

Re:PHP On Pie takes a fresh new approach. by jmathai on Sunday September 12, 2010 @12:05AM (#1683007)
Re:PHP On Pie takes a fresh new approach. by bithub on Sunday September 12, 2010 @05:22AM (#1683355)
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.

Re:PHP On Pie takes a fresh new approach. by EGreg on Sunday September 12, 2010 @09:32PM (#1685144)
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.

Re:PHP On Pie takes a fresh new approach. by jameskilton on Sunday September 12, 2010 @10:39PM (#1685294)
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.

Re:PHP On Pie takes a fresh new approach. by EGreg on Monday September 13, 2010 @03:14AM (#1685835)
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.
Re:PHP On Pie takes a fresh new approach. by petervandijck on Sunday September 12, 2010 @05:14PM (#1684569)
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.
Re:PHP On Pie takes a fresh new approach. by crazydiamond on Sunday September 12, 2010 @01:38AM (#1683131)
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.

Re:PHP On Pie takes a fresh new approach. by mike-cardwell on Sunday September 12, 2010 @06:58AM (#1683437)
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.

Re:PHP On Pie takes a fresh new approach. by EGreg on Sunday September 12, 2010 @10:09PM (#1685224)
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.
Re:PHP On Pie takes a fresh new approach. by mcantelon on Sunday September 12, 2010 @02:34AM (#1683190)
Nicely done site, but I would say that immediately your site should tell what makes your framework stand out from the crowd.
Re:PHP On Pie takes a fresh new approach. by dangrossman on Sunday September 12, 2010 @01:54AM (#1683153)
I want to see something significant built with the framework. That's what gets me to try something new.
Re:PHP On Pie takes a fresh new approach. by mrjbq7 on Sunday September 12, 2010 @03:01PM (#1684306)
You have a typo on #10 - s/Competely/Completely/.
Re:PHP On Pie takes a fresh new approach. by EGreg on Wednesday September 15, 2010 @01:36AM (#1693424)
Fixed, thanks.