Should I use a framework when developing a project in php? or I used my scratch php code to do it?
Should I use a framework when developing a project in php? or I used my scratch php code to do it?
Last edited by ganjasensation0098; 09-30-2010 at 04:40 AM.
HERB is the healing of a nation. ALCOHOL is the destruction.
If you're a single programmer working on your own project, it would likely be best to cook from scratch. That's generalizing in a big way, though.
There are a couple of types of frameworks to consider. One is the class of environments that work similarly to Ruby on Rails, like CakePHP. These can be characterized by the "convention over code" principle -- as long as you can define the data consistently, much of the work is done for you (the databases will be built in a particular way, an object-relational map layer will be created for you, and basic UI views, forms and often AJAX actions will be generated). Your task, then, becomes a relatively simple matter of customizing what the framework provides. Of course, if you stray too far from what's in the box you will lose the advantage that the framework provides. In fact, you'll probably find yourself fighting the system at every turn, and there will be much profanity.
Then there are "enterprise class" frameworks. Like .NET and J2EE, they provide a lot of classes that do the kinds of heavy lifting that you'd normally have to do in your own code. But then you've just traded writing the code for a constant reliance on reference material (don't even try it without a framework-aware IDE like Zend Studio). The advantage of these frameworks is consistency when the project gets large and there are a lot of programmers working on the code base; the disadvantage is that you end up loading and running a lot of heavy code that you really don't need to be running in order to get the job done. Do you really need to have string handling classes that are immune to the Turkish I Problem?
If you're coding with an eye to getting a job in the corporate world (or at least that part of the corporate world that isn't married to the Microsoft stack), then jumping down the rabbit hole to the land of frameworks might be a good idea. If you're doing it for yourself (or with an eye to consulting to the SME world), then learning to create code that is robust, lightweight, maintainable and does no more than it needs to do will serve you far better.
But that's just an old fart's opinion.
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)
Thanks for that essellar. Right now, I'm working on a project only by myself (that is almost finished) and I use codeigniter framework. In my next project, i'm confused if I should use the framework again or create my code from scratch.
HERB is the healing of a nation. ALCOHOL is the destruction.
In this case then I would ask whether you enjoyed using the framework and whether you felt it helped or hindered you? Also, use of a framework in your next project may also depend on the size and expandability you desire from it; a good framework may make light work of some major projects, but for smaller ones it may make little or no difference to how you interact with the data.
As of now. I think I should a framework and maybe if the framework does not fit in my needs, thats the time that I will make my own framework.
HERB is the healing of a nation. ALCOHOL is the destruction.
The thing is, if you are going to make some simple PHP apps you don't actually need any framework, on the contrary, it would be more complicated and you'll end up with much slower app comparing to what you could do with pure PHP. On the other hand, if you are making your own custom CMS solutions or any other complex PHP app or system your best bet is to use PHP frameworks. I do a lot of complex PHP systems and apps and from my experience frameworks are always a good thing.
As for the codeigniter I find it quite useful. I started using it few years ago and I'm still using it. Simply put I love it.
To be honest, once you start making some crazy stuff you'll eventually end up making your own framework![]()
Last edited by farscapeone; 10-03-2010 at 12:45 PM.
Which framework do you think is the best?
In my opinion zend framework is best because they are part of php project and offers certification courses too which has value in IT industry.
Liked this? Click on theicon on the bottom of post to make me
.
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
There is no "best framework"; there is only "the framework that makes my job simplest". For some types of applications, that may mean something simple and small like CodeIgnitor (you really can build a blog in twenty minutes -- well, twenty minutes plus however long it takes to mess about with graphics and CSS). For others, it means something like the Zend Framework, the PHP world's version of Java Enterprise Edition (a team of twenty developers can build a blog in twenty weeks -- but it can support twenty thousand simultaneous users distributed across twenty nations using twenty different languages, and it can tie in to your catalog and invoicing systems, track customer service issues, and prepare the buffet for your launch party).
You don't have to use everything a big framework provides, but it can be frustrating to have to wade through the documentation in order to find what you do need if you're not working with it all full-time. Smaller frameworks may conveniently leave out things you really wish you had, but you can always add to them as necessary.
If your project is relatively simple (a handful of UI elements dealing with a relatively small number of tables across one or two databases), you may find that something like CodeIgnitor or CakePHP will get you to 90% in next to no time. For realz. (Both of these frameworks are excellent, by the way. Which one you'd use is really a matter of taste.) You can bang out a small site with a blog/news section, a forum, a contact form and a way to create semi-static content pages in a couple of days (modulo design work). But you may find that you have to step outside of the framework in order to provide unique features, and that can be frustrating -- sometimes it's difficult to make framework-provided features work with your custom code and vice-versa.
I've always preferred the "bottom up" approach to programming myself. As Leviathon noted above, you are going to end up with your own bag of tricks eventually by simply surviving the development wars, and as long as you don't throw everything away at the end of every project, you'll wind up writing applications in your own version of the language rather than in raw PHP. The difference between your "framework" and the off-the-shelf varieties is that there will be no black boxes, no surprises, and no absolute limits.
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)