views:

1305

answers:

11

Hi,

Ive been researching into PHP frameworks. I am trying to understand the utility of these frameworks.

For e.g. does facebook use a framework? I guess not.

Also, say I am developing a product which I want to sell users. Now suppose a use a framework like Zend, then I am unnecessarily imposing restrictions of using PHP 5 only. A lot of servers are running on PHP 4. So is it worth it in that sense?

I know CakePHP supports both 4 & 5. But a lot of places they have mentioned that CakePHP lacks scalability. I know that all frameworks add their own overhead because of bootstrapping.

Also, how useful is MVC model. Is it worth enforcing in application development (especially if some of them maybe quite small and easy to manage)?

Thank you.

UPDATE

I have been going through a lot of frameworks- CakePHP, CI, Zend... And am honestly confused. Which one to use? How to decide which is better than which? Also, I plan to develop products (like wordpress) which users can download and install on their servers. If I use Zend then I must make sure that the user has a host which supports Zend, if I use Smarty then the user's host should support Smarty. Now that will definitely limit my customer base. I want it to be as expansive as possible (for maximum profits ofcourse :)

For example, I dont see any frameworks being used by wordpress, but it seems to be doing pretty well... so...

Please suggest the best option....

Thank you again.

A: 

The utility of any framework is that it provides you with higher-level abstractions that enable you to focus more effort on solving your domain problem and less on providing infrastructure on top of the basic language to support your system.

As to using a framework that ties you into a particular version of PHP, that has to be guided by both the technical (what features do the framework provide me?) and the business (what impact does it have on our sales?, what impact does it have on our costs (i.e. vs rolling your own framework / not using a framework at all)?)

MVC is just another architectural pattern. For small sites (definition of small left as an exercise for the reader) it will introduce too much complexity compared to the benefits it brings.

Giraffe
+4  A: 

"Framework" is a very loose term, it's more of a buzzword (like Ajax).

Facebook probably doesn't use any framework that you can download, but I will bet my pants (well, they're a bit worn and torn already) that they something that could be called a framework. Sure, it might be suitable only for Facebook, but if you look hard enough, a framework will emerge.

I can easily imagine that no web framework is suitable for all developers, in all instances. They are built always with an assumption. Some broader, some more narrow, but still there's an assumption. Without doing any research, I hazard a gamble that there's a widespread assumption across many frameworks that the database will never be clustered. Also, there's proabably an assumption that you are okay with using objects your model for the ORM, if there is such a thing.

...and so on. If you absolutely need the best solution for your problem, write your own. On the other hand, if you find a Framework that suits your needs, go ahead and use it - once you know it inside-out, you probably will become more productive than writing everything from scratch.

The MVC (again, a buzzword; there are other methods of separating different parts from eachother) is just a method to make your code more clear and less spaghetti-y. I would say that with a larger project, it becomes quickly unmaintainable without proper separation. MVC is as good as any other.

Henrik Paul
+8  A: 

First off, do use web framework. It can save a lot of time doing the most basic stuff otherwise you would have to write on your own, i.e. URL rewriting, session handling, data persistence.

Second, PHP 4 is dead. It has been officially announced that it has reached end of life and no security updates are to be released any more. Move on to PHP 5.2 or newer and don't look back.

Don't worry about scalability too much, unless you know you will grow exponentially. Performance issues are often much overrated and in most cases it is much cheaper to get a hardware upgrade rather than code rewrite. Obviously, it makes more sense to have reasonably bug-free software that runs slow than buggy or incomplete application that excels in performance.

MVC is a really useful architecture, that if used and understood properly, can speedup development time and lower software maintenance costs. It is popular belief that using MVC for small projects is an overkill, but I disagree. MVC is not a big overhead and software tends to grow, so it is just wiser to design with future growth in mind rather than later rewrite.

Michał Rudnicki
Yes, PHP 4 is dead, but I wish all hosting providers would upgrade!
Bill Karwin
@Bill Karwin: Why do they need to upgrade? There are enough hosting providers with Python, Ruby, and even PHP5. For 2 to 3 € a month.
stesch
Fair enough, they'll just lose business if they don't upgrade. Especially the next time CERT publishes a security flaw in the (now static) PHP 4 code. What I should have said is I wish *my* hosting provider would upgrade! :-)
Bill Karwin
+1  A: 

I'm almost certain Facebook uses a framework. It's probably one developed in house (if it's your core business you better build it yourself), but still a framework.

About the benefits of the common public frameworks, they are there, they mostly work and, most importantly they help you manage complexity by offering predefined means to do things (ie, taking decisions for you).

For small sites there probably isn't a real need to use them (unless you want to learn them), but then, how can you tell if the site isn't going to grow.

MVC is mostly a good way to develop interactive applications (was born in the desktop, where it fits better), which has been 'ported' to the web environment and it mainly helps to get your concerns separate aiming to ease maintenance.

Each framework implements its own version of MVC (they all have the same common idea, but they usually differ in the actual implementation and will have their own quirks).

If you have the time, roll a couple of apps with the framework you like the most and compare it to how you would have done it by yourself. That will teach you more than anything you can read here.

Also, there is something called a 'sweet spot' for frameworks which is the point at which your application is best suited for the particular features a framework offers.

Vinko Vrsalovic
+2  A: 

A lot of servers are running on PHP 4.

Is it still true? Surely some years ago when I started to learn PHP, but probably no more today. Hey, even my free host has switched.

Beside, I don't know how big sites like Facebook or deviantART are developed, but I guess that if they don't use an existing open source framework, they have developed their own. Something you might not have the luxury to do in small projects with tight deadlines. Beside, why re-invent the wheel (and repeat old bugs, fall in old security flaws, etc.)?

PhiLho
+2  A: 

I reccomend using PHP framworks ONLY after you are really proficient with "bare" PHP. Using something without understanding underlying principles can really complicate things a lot.

I'm currently getting into Zend - after working with bare PHP for several mistakes. I feel I could write every individual part of it myself, but it would take hell a lot of time. But using framework just because it can do things you couldn't do yourself, it's the bad way.

The MVC may be a buzzword and it may be annoying at times (when you want to do a "Hello world" and you need to create 6 files to do it), but once your project grows over certain level, it becomes priceless. Nothing is worser than refactoring a thousand lines of spaghetti code.

Ad PHP 4: I didn't encounter PHP4 only server for months, I don't see a reason to adapt to it. Using a PHP 4 compatible framework may also mean it doesn't use the advantages of PHP 5 (which would be a serious backside).

CommanderZ
A: 

Go for the frameworks. Reuse code, don't reinvent the wheel, unless of course you are learning PHP. If it's the case I really advise you to mess around with it for some time, and then go for the frameworks.

MVC is a design pattern that separates the code in 3 tiers in such a way that it really is worth applying it. You get things very organized and can always find the code you are looking for, whether you have 5 files or 5000. I wouldn't concern about the overhead unless you web app/site is critic and needs top notch response times.

rogeriopvl
A: 

php frameworks have received a lot of criticism for not being able to scale. In order to use a framework, you should understand the tradeoff of a very scalable site vs easily maintainable code (depends on your code).

A: 

I am a programmer that is with a company that requires PHP 4. I think it's ultimately not the concern of the programmer to use PHP 4 or 5 or whatever. I think it boils down to what the client wants.

If he requires PHP4 then I should use it or I don't get the job.

It's probably why I am glad there's CakePHP and CI. Of course, I love PHP 5 and can't wait for PHP 5 projects.

Thorpe Obazee
A: 

My opinion is that someone have to learn php at a good level so to understand what he is doing and then to choose a framework, learning also OOP and design paterns. I recommend Yiiframework.com,cakephp,Symfony

dimis
A: 

dude.. use MVC.. or u will go mad. Scratch php wud be much time consuming and wud hav 2 tier kind of an architecture. If you end up making a gr8 product & wish to change something here and there.. u wud go mad without an MVC framework. I suggest you use CI.. it is compatible wid php4 and is also easier than cake !

Pratik