Page 1 of 2

What's your take on using frameworks?

Posted: Sun Apr 27, 2008 5:22 pm
by josamoto
I dunno, I get frustrated having to code PHP and stuff, but I have to, so I think I can easy things out a bit by using a framework like CodeIgniter, CakePHP, PEAR, Zend Framework or whichever, and I sometimes just find...even more frustration!

There just always seems to be something going wrong, sometimes little things to tick one off, and other times...well...suicide is not an option so I have to keep coding. :)

Anycase, I want to know what you guys think about frameworks overall. Isn't it sometimes better to write your own reusable code that loosely coupled and nicely object oriented in a "I want to reuse that" fashion, or do frameworks REALLY help that much?

Thanks! :)

Re: What's your take on using frameworks?

Posted: Sun Apr 27, 2008 7:23 pm
by nowaydown1
I don't mind frameworks. I've used most of the mainstream frameworks around (ZF, Cake, CodeIgniter). I think the value of using a framework will largely depend on the scope of your application, your long term goals, and your own familiarity with PHP & existing frameworks out there.

What about non-framework based PHP development is frustrating you? If it's stuff like worrying about code for things like input filtering, database abstraction, and standard form validation--then I could see that a framework would probably be worth the learning curve. If your frustrations stem from other issues, then I'm not sure moving to a framework would ease your pain any :D

I think for each developer it's honestly going to be different. I use frameworks, but not for every project that I work on. You wont always need all the functionality that a framework provides. On some projects, it just gets in the way of getting things done. That said, on larger projects with tons of functionality, it can be a blessing.

Re: What's your take on using frameworks?

Posted: Sun Apr 27, 2008 8:15 pm
by John Cartwright
josamoto wrote:Anycase, I want to know what you guys think about frameworks overall. Isn't it sometimes better to write your own reusable code that loosely coupled and nicely object oriented in a "I want to reuse that" fashion, or do frameworks REALLY help that much?
This is exact reason why I've joined the development team for the skeleton framework, which should have a release in the near future. I've never been satisfied any of the current frameworks. I'd say Zend Framework comes the closest to lose coupling, but IMO has failed miserably with the view/controller coupling. Having interdependent components is extremely important to me, and is useful to the community since if you have a problem/disagree with our implementation it is extremely easy to roll out your own solution.

Re: What's your take on using frameworks?

Posted: Mon Apr 28, 2008 5:29 am
by Mordred
Having interdependent components is extremely important to me, and is useful to the community since if you have a problem/disagree with our implementation it is extremely easy to roll out your own solution.
While I understand your position perfectly, I approach this problem from the other direction (since I'm writing framework code for my own use). For any (most) given situation, there is one right solution (yep, it's easy to say so if it's only one coder :) ) so I implement it and move on. Usually I do it in layers, so the code is (maybe) swappable, but I don't care much if it is. Also the values I put in an interface to doing something are different from the conventional values (it appears). I strive for: short expression, sensible defaults (which would do for 99% of the use cases), and just-once problem solving (i.e. once a problem is solved, it shouldn't be solved again).

@josamoto: If you can clearly state (for yourself) what problems you want to avoid with a framework and in what way, this should make the process of choosing one easier.

Re: What's your take on using frameworks?

Posted: Mon Apr 28, 2008 12:15 pm
by Christopher
Mordred wrote:While I understand your position perfectly, I approach this problem from the other direction (since I'm writing framework code for my own use). For any (most) given situation, there is one right solution (yep, it's easy to say so if it's only one coder :) ) so I implement it and move on.
The question is: Is the one coders "one right solution" actually very good or a best practices solution. I have found over the years in my own code that the answer is no.
Mordred wrote:Usually I do it in layers, so the code is (maybe) swappable, but I don't care much if it is. Also the values I put in an interface to doing something are different from the conventional values (it appears). I strive for: short expression, sensible defaults (which would do for 99% of the use cases), and just-once problem solving (i.e. once a problem is solved, it shouldn't be solved again).
I agree ... the problem is getting to a good design. I have found that exposing the code to public review -- like your own excellent and blistering critique of some SQL code recently ;) -- helps produce better code.

Re: What's your take on using frameworks?

Posted: Mon Apr 28, 2008 1:54 pm
by Zoxive
josamoto wrote:Anycase, I want to know what you guys think about frameworks overall. Isn't it sometimes better to write your own reusable code that loosely coupled and nicely object oriented in a "I want to reuse that" fashion, or do frameworks REALLY help that much?
This is exactly why I use my own. So I know exactly how everything works, and It ingrates with my coding style.

The only down side is, it took me quite a while, and many many rewrites to get to where it is now. (And it still isn't perfect and probably never will be, but it satisfy my neediness.)

Re: What's your take on using frameworks?

Posted: Mon Apr 28, 2008 4:43 pm
by Kieran Huggins
I think a good framework is great for writing applications, especially with several developers since it promotes a certain amount of predictability.

Personally, I like a framework that handles the basics and then gets out of the way, but I've never been a fan of Zend or those like it.

My newest love is merb - it's nice and light and covers all the basics. Plugins are available for extra functionality so the core stays tidy and quick. Even views are optional, as whatever the controller action returns is sent to the browser. Also, it's ORM agnostic!

Merb + Haml + jQuery + Datamapper == teh hawt.

Sorry, ruby only ;-)

Re: What's your take on using frameworks?

Posted: Mon Apr 28, 2008 6:20 pm
by josamoto
I see Zend 1.5 is out now, and by looking at the docs, it appears they have done a bit, especially when looking at the manual. It explains everything in the finest detail. By peeking at the code snippets, it appears straightforward to use and you can include/require just what you need. There's probably a chance I guess, that those who use a framework like this will probably only use about 5-10% thereof. It's just like PEAR, but I find some PEAR packages very poorly documented.

I have recently moved to developing Flex applications with PHP in the backend. So AMFPHP is my new best friend, but it does not work easily with CodeIgniter which I liked quite a bit.

Also, my MVC is much less "PHP oriented type of MVC" now, because my View and Controlling is done by Flex, and PHP only acts as a "service" in the background spitting out Action Message Format data to Flex and responding to it's queries via AMFPHP. So the V and C has moved to Flex/Flash, and only the M remains to PHP.

MVC frameworks don't really help me anymore. I need the core stuff that does things on demand, such as send emails, do database stuff and make my coffee in the background. :)

Anycase, thanks for the many replies!

Re: What's your take on using frameworks?

Posted: Mon Apr 28, 2008 6:47 pm
by RobertGonzalez
I am a huge fan of the Solar Framework from Paul M. Jones. He has contributed to the Zend Framework. His framework just seems so elegant to me. No bloat, no unnecessaries. Just good, clean, elegant, readable code.

Re: What's your take on using frameworks?

Posted: Tue Apr 29, 2008 11:45 am
by Maugrim_The_Reaper
I develop for the Zend Framework - totally biased ;).

Any framework is the same, you get out what you put in. I know the ZF backwards so I find it stupidly easy to develop with. Give me Code Igniter and I'll probably choke and collapse one fine afternoon and never recover!

One of the things I find is that a good example dishes out some background on the bigger picture. I'm running a series on my blog about using the ZF to create a blog application (finally dug a foxhole to assault my growing need to replace S9Y with a custom blog so I can tinker with it - I like tinkering a lot ;)).

At the same time, lots of people know I think the ZF has failings. The View integration I consider a horrible mistake because it's so confusing to try tracking just how deeply routed that interdependency has become - to the point simply shuffling simple View conventions is a good idea if you like being driven insane.

Still, out of the bunch it's the only one I really enjoy using, followed by Symfony, and then followed by...merb. As someone said earlier, merb is pretty good if you want come down from Railsland.

Re: What's your take on using frameworks?

Posted: Tue Apr 29, 2008 2:49 pm
by josamoto
Nice to have a ZF developer here. I just downloaded ZF about 2/3 nights ago and I am definitely going to look at using it full time. :)

Re: What's your take on using frameworks?

Posted: Tue Apr 29, 2008 10:28 pm
by alex.barylski
but IMO has failed miserably with the view/controller coupling
Care to demonstrate what you mean by view/controller coupling in Zend and how it'll be improved upon in Skeleton?

This is directed at anyone...I'm interested in reading all opinions :)

Re: What's your take on using frameworks?

Posted: Wed Apr 30, 2008 2:48 am
by Christopher
Hockey wrote:Care to demonstrate what you mean by view/controller coupling in Zend and how it'll be improved upon in Skeleton?
I can't speak for Jcart, but I can try to address your question.

I think the simplest example of "view/controller coupling" in ZF is the fact that the Action Controller has a render() method. The ViewRenderer helper takes it a step further, and plenty of people now turn on ViewRenderer in their bootstrap. There is a chunk of code in the Action Controller hardcoded to manage Zend_View and ViewRenderer.

I should note that I don't necessarily have a problem with providing support for Views in the Controller or even combining them when necessary. But ZF through its design seems to do two things in my opinion -- it encourages you to render PHP templates and discourages you from creating actual View objects. You can create View objects, but ZF really considers a PHP template to be the standard presentation logic. Again, this is not necessarily a problem -- especially if you like that solution. By comparison, Skeleton take a more neutral position on Views and considers template libraries to essentially be View objects that wrapper the specified template.

Then there is the requirement to have use their functionality. Zend requires that Action Controllers extend their Zend_Controller_Action class, Skeleton does not. You can use plain objects as and Action Controller if that's all you need, or extend them with the A_Controller_Action if you want that extra functionality (loading, forward, flash, etc.), or roll your own. Naming is also flexible. If you want the extra capitalization and suffix of ZF you can do easily that, but by default Action Controller's names are the same as the action.

And finally is the weight of the Zend classes. For example, though the ViewRender is seen as a shortcut of sorts it actually (like many things) requires a Zend_View to function. So ~15k for the Action Controller, ~20k for the ViewRenderer and another ~20k for the Zend_View -- and all the additional misc. includes. Compare that with ~4k for the Skeleton Action Controller and ~4k for the View and you have a noticeable difference in speed and memory usage. I think for a minimal Hello World using Action Controllers, Skeleton is about 5 times faster. Obviously that is not that important a metric, but it gives you an idea of the general difference -- and with Skeleton you can go lighter, whereas you can only extend with ZF.

I hope that give you a sense of a few of the differences.

Re: What's your take on using frameworks?

Posted: Wed Apr 30, 2008 1:49 pm
by josamoto
I was wondering? Could you guys probably recommend a website or two where you can download specific scripts, not frameworks, that do specific things.

It would be nice to have an online, community developed repository of PHP code that I can for example search for a script that handles sending an email, or handles a mysql database, download the script, stick it in my scripts folder and simply require/include it and fire away.

I'm thinking about something in the line of a searchable database, with readable code that is simple to use, purpose driven, small and readable and easy to install...and if documented, that would be a bonus, but I mean, simple libraries can have the documentation right in the source file, PHPDoc style.

Re: What's your take on using frameworks?

Posted: Wed Apr 30, 2008 1:50 pm
by josamoto
Thanks for the link on The Solar Framework. It looks interesting.