PHP is a server-side scripting language used all over the world for general purposes. Earlier, PHP used to be the short for Personal Home Page. It is now known as ‘PHP: Hypertext Processor’. It is very helpful for web development and can be blended into HTML too.
Moreover, it is easy to learn. PHP includes many functions without the need for namespace importing. You can decide whether to write object oriented code or not. The syntax is also similar with weakly typed variables.
The simplicity in using PHP sometimes acts against it. Since there are very few coding restrictions, developers tend to write a bad code. The answer to this is definitely to use a framework. There are various PHP Frameworks available today like Zend Framework, CakePHP Framework and CodeIgniter. They provide a strong organization for your application and follow the commonly used MVC pattern.
Some of the other advantages of using a framework are:
- MVC structured code:MVC or Model- View- Controller is a well-known design pattern that demarcates the database and business logic from the presentation layer. This results in simple, clean and understandable code.
- Maintaining the coding standards:The MVC code is easy to write and also follows the code restrictions. Due to a uniform and standard coding, things are simpler and bugs can be resolved faster. This will save you a lot of worry and it will be easier to find out where the problem lies.
- Attractive URLs:Almost all these frameworks make sure that your URLs look attractive and easy to access. Apache takes care of requests for a particular URL, which further invokes the central framework object. The end-users can only see the URL pasted on their browser, and cannot make out that you are using PHP for the same.
- Get all the help you need:When you use a PHP framework, you no longer need to manually enter all the validation criteria for forms etc. The only thing you should do is instantiating a new form validator object and instruct it as you wish. It will handle the rest.
- Finish coding faster:Frameworks help the developers to write code in lesser time than usual. This leaves them with some extra time for themselves.All said and done, there is always the option of writing your own framework for your application. However, when you have something like CakePHP doing a lot of nifty things for you or a Zend that provides great functionality, you can select one depending on your requirements. So just choose a framework and start coding!
|
Percy's 68005 Gaskets Header Collector US $8.99 Auction Ends: Tuesday Feb-09-2010 3:45:26 PST | Watch this Item |
|
Percy's XX Carbon Exhaust Header Gasket 68031 US $19.95 Auction Ends: Tuesday Feb-09-2010 4:16:03 PST | Watch this Item |
|
Percy's XX Carbon Exhaust Header Gasket 68019 US $19.95 Auction Ends: Tuesday Feb-09-2010 4:21:29 PST | Watch this Item |
|
Percy's XX Carbon Exhaust Collector Gasket 68006 US $10.95 Auction Ends: Tuesday Feb-09-2010 4:39:31 PST | Watch this Item |

24 Comments until now
Hi,
You have made a great question, but in my point of view, you decided for an awful approach.
I totally agree that using a framework makes the developer to follow more Coding Standard, imposed by the framework, that PHP language doesn’t.
Although when you give credits to a php framework on the point, “Attractive URLs” and “Finish coding faster” you give it all to loose.
It’s not a framework responsibility to have fancy Urls, you can make it with a simple .htaccess .
Is not that straight, that if you use a PHP framework you get your coding faster, depends on the project that you are using.
Please note that i understand the pro’s and con’s on using a coding framework, either a PHP, Javascript or other language, although i think that when you are trying to talk about it you should give both sides.
It’s too much to say “So just choose a framework and start coding!”.
My 5 cents
Also, using a framework does not make you a better PHP developer. It makes you a better framework developer.
Yes, in raw PHP you can write bad code. But as you do so, you learn to write better code. Over time, you will be laughing at your first “Hello World”.
Frameworks hide too much of the real language from you. Good luck finding a job when all you know is Cake or CodeIgniter, etc. Employers want someone that has proven they can LEARN not just follow along inside a framework.
I agree with that 100%. I feel that writing PHP code using frameworks too much can often stunt your growth in PHP knowledge and standard practices. If you want to become a better PHP developer you need to develop in PHP without any crutches. The more mistakes you make, the more you will learn.
As much as I love frameworks and template engines, I have to agree with the other commentors by saying that if you want to learn quickly, make a ton of mistakes. But, from personal experience, if you want to learn even quicker than that, run a blog where you post code snippets of your own. I did this and have been burned quite a few times by people who can take your 20 line code and convert it to a 3 line routine.
@John – That is a good idea. I am kind of doing this right now with my twitter cloud service that I provide for my readers. I wrote the code quickly, without and design. Since it is just a small service, I whipped it up as quickly as possible. I’m sure that if you download the code, it could be reduced to half its size, lol. Thanks for the comment.
I agree that one should not jump straight to using a framework when learning a language. A framework hides a lot of the complexity and potential uglyness of PHP — which is a good thing — but when you’re just getting started it can be healthy to see all the gory details for yourself.
However, once you realize the tediousness of it all, switch to a framework or develop one yourself. As no PHP framework quite fell to my liking (few/none support both XSLT and Smarty for instance), I developed the Kolibri web framework which fits my style and made me learn a ton along the way.
This is a timely article for me. I’ve been absorbing PHP as fast as possible since first discovering it (and getting addicted) in June. I’ve built a basic blog platform using procedural code then latterly got interested in OO PHP and built a *very* basic CMS. I think I have a firm grasp of the basics and recently scored “Advanced Master” in a Brainbench test.
Over the past few weeks I’ve been grappling with The Zend Framework and, to be honest, I’m struggling big time! I’m hoping to make web development my new career next year, hence the interest in a framework to hopefully speed up production, but from some comments it seems I might be trying to run before I can walk. As I said, I’m really strugglin with ZF anyway.
I would be interested in any thoughts regarding this.
@Doug, apologies for hijacking your post somewhat! Also, I’m (red/green) colourblind and really struggle to read the names and links in your comments section until I hover over them.
Loving your site though
Guys, please.
The “Cowboy Coder” attitude is what makes 90% of the IT experts around not eligible for serious jobs (see Bjarne Stroustroup’s recent article).
Not working with a framework means you reinvent the wheel every time.
Means making it almost impossible to fit you in a large team, not because you don’t know framework XYZ but because you have the “holier than thou” attitude.
Most of us are NOT better than the collective minds of hundreds of people that work on frameworks.
What you are right in saying is that you have to learn PHP first.
Frameworks are for experienced people: Rails has the same problem in even worse form, as most Rails coders had their first exposition to Ruby through it.
Might I recommend reading a little McConnell or Brooks?
PHP actually now stands for PHP: Hypertext Preprocessor … the ‘pre’ is key
@Danny – That’s true! Thank you for your input.
I have to disagree with Luca on the comment “Not working with a framework means you reinvent the wheel every time.” Isn’t the entire idea behind classes and objects code re-usability? Just because you don’t use a framework doesn’t mean you’re out there writing the same connection string over and over again. Most experienced developers tend to create a collection of their most commonly used functions and classes that roll with them from project to project. Here at Medtronic, my team uses a shared directory (surprisingly called shared_resources) to store these common solutions. Yet, we don’t use PHP frameworks.
In my experience with Zend and Cake I have found them to be very painful tools to work with. I don’t like the idea of losing control of my application or website under the guise of faster process. Why is faster better? Will my product be better if it comes out faster? I don’t think so. The reason I became a programmer is because I enjoy building the applications, not configuring them.
Anyone can write bad code with or without a framework. The most noted comments I have seen refer to frameworks as imposing some development pattern on the developer. What good developer needs to have anything imposed on them?
In the end, like many things, it comes down to the developer. If you use discipline and take pride in your work you’ll write solid code with or without a framework. I look at building an application as a carpenter would at building a house. The right tool for me will not always be the right tool for you.
I have experience with CodeIgniter and Zend Framework and have been writing PHP (my first foray into programming) for around a year. I’m also the kind of guy that likes to learn how things work, rather than how to work them. As a result of this, I built my own framework with careful attention to design patterns, security and re-usability.
I would question how many of the above commenters’ negative opinions on frameworks apply to a home-rolled one where I have taken care to understand everything that goes on. Am I destined to be inflexible in my working practices?
I use my own little “framework” (nsslive.net/codon), where I’ve rolled up my most commonly used stuff, in an MVC format, but leaving it open-ended enough to not be locked into a certain way of doing things.
Something that I haven’t seen noted much is the overhead due to frameworks – Zend is very slow (one company I remember using Zend bragged how their pages loaded in under 70ms). Sometimes frameworks are just too overly complicated for the task at hand. They can be over-imposing (too many steps to do something); I also don’t like running these huge frameworks without knowing in some detail about what’s going on under the hood. Barebones is how I like it (which is what my “framework” is).
Doesn’t mean you’re re-inventing the wheel, but in your “bag of goodies” you’ve already got a set that you’ve designed and know in and out.
“Most of us are NOT better than the collective minds of hundreds of people that work on frameworks.” – Most of us may not also do not know how to use frameworks either, they don’t help much with learning the language, but you don’t always know the best way to use ‘em either.
Luca’s comment is the only comment worth anything. Go pick up a McConnell book and take it from there.
On a side note, any PHP framework based on PHP4 and its ridiculous, fake “object model” is a farce.
I’ve been teetering on the edge of using Zend framework for ages.
Every so often i go through a process of:
* php script needs writing / amending
* oh Zend Framework has a solution
* blimey i’ve got to read a short novel of documentation before i can implement this simple functionality
* it’d be quicker just to write it myself, from scratch + my own library of code
By this time I’m feeling fed-up that i’d wasted so much time investigating the option of using the framework and groan when i read things like “So just choose a framework and start coding!”.
I know that its better in the long run to use a framework – for team work etc.
But , I just never seem to be able to justify the time to learn them. Especially when i can get a particular task done quicker by using my own, stuck-in-my-ways, methods.
I think frameworks are only “AMAZING” for writing ‘new applications’. I’ve found it very painful trying to plug it into my existing code.
In summary: I think Zend Framework is amazing – i just wish i had the time to learn how to harness it.
I think an important aspect of using a framework is consistency and maintainability. When working in a team, or when developers come and go ( as they always do), it is invaluable to have a consistent approach, with documentation and tutorials for new developers to ramp up to speed with. While developers may learn more by pioneering our own approaches ( and I encourage this outsiode of critical projects), it can cause a lot of grief for a company or developers left to maintain projects that do everything their own way.
Brad,
There’s already a solution available to companies in order to maintain consistency among their coders: code reviews. Within my team we are not allowed to push any of our own code to production servers. Every line of code is reviewed before it is pushed to production. This adds time to the process, but it saves time in the long run with conventions compliant code that all of our developers are familiar with.
When I was a young, would-be Marine on Parris Island a Drill Instructor told my platoon something while learning to drill that has been surprisingly influential in my life. He said, “Slow is smooth, smooth is fast.” A note we should all keep in mind when programming.
I’m a Zend Framework user.
About 2 years ago, Zend Framework was responsible for pushing me over to OO PHP. I wholly hold ZF responsible for that, it provided the mechanism for me to learn. It also taught me the MVC pattern as well as enabling me to recognise OO patterns such as Registry, Singleton and Factory.
Simple stuff I know but 2 years ago, I hadn’t a clue.
@ronny
You’re ‘complaining’ because ZF has a ’short novel’ to read when you want to use a component. True. I’d rather have a short novel if it means use cases, code examples and explanation, than something half-baked.
It’s proper documentation, it’s actually useful when you can’t remember how to use minorMethodFoo(), rather than rely on hand-me-down knowledge or use the API to work it out yourself. It’s 95% there, with examples, with use cases, if theres an alternate interface, it’s most likely documented. It’s something to be positive about, it’s not a barrier. It’s there to help you when you don’t know already, you can use it to help yourself. There is very little need to ask someone else if what your asking about is already in front of you.
Also, You don’t need to read the whole documentation about a component before using it, much like you don’t need to read the whole recipe before fetching the ingredients.
Best Advice:
1. master PHP before learning Frameworks or you’ll be stunted
2. don’t use Frameworks for small projects
3. if you can come up with your own Framework, so much the better, since you’ll have complete control
4. if you decide to use Frameworks, be ready for a long learning curve to master it, but it’s important to master it to make full use of it
5. choose a Framework that’s fast, well-designed, good documentation, good community
The divide between “professionals” and “hobby geeks turned paid monkey” is quite obvious. Much like everything else in life people keep looking for ONE way to do everything. It doesn’t exist.
For every code junkie that thinks writing their own library/framework is better than getting whole heartedly behind a framework is better – there’s a reason your life is the way it is and why you’ll have a very hard time becoming VP. You’re selfish, insecure and afraid.
Selfish because you keep focusing on your convenience and habitual patterns instead of the company’s bottom line. Insecure because rolling your own libraries makes you feel important and irreplaceable, after all who knows your code better than you? Afraid because joining a community of true professionals and freely contributing forces you to be scrutinized and to continually challenge yourself to increase your skill set.
There are millions of people who can get the job done. There are millions of people just like you all over the internet. There are kids in India right now that would steal your job for less than 1/10th what they pay you and you better believe they’re crawling the web trying to learn more.
At the end of the day us little people at the bottom have to focus on the objectives of those at the top. We are part of a massive global economic system with the internet becoming more accessible. Information is free. Programmer’s are losing their value. Big business need business leader’s not just code junkies. When you align yourself to the company’s bottom line – ecreased expenses, ridiculous deadline, time-to-market, return-on-investment, competition, increased profitability, etc., etc. – you will find yourself
Keep in mind the things like PEAR, PCEL and other “collections” are already widespread. The benefit of frameworks and widely supported libraries is that they have the opportunity to be stress tested through a greater variety of actual use scenarios that your private code doesn’t get. Also, from an enterprise perspective (you know the people that pay your salary) they are going to be very interested in long term product support, maintainability, scaling, project cost, etc.
Building your application of top of a popular and widely supported framework, especially one like Zend Framework which works hard to maintain an enterprise friendly brand and support system is the difference between whether or not you’ll have a job in five years. Zend’s name and certification system is what enterprises will place their confidence in. So you can jump in wholeheartedly, contribute to make the framework better or look for another line of work because you’ll be replaced by someone who is not only technically competent and skill but also a great business focused leader.
If you want a life that is more well rounded and free from the plagues that affect over 97% of the world then you must be swift to discern it’s patterns and run in the opposite direction. Flexibility is freedom.
@luke
I agree with you Luke, and ZF had a very similar influence on me. The first time I read the docs, when ZF was young, it inspired me to get into OOP. It was the moment when I decided to buy and read the PHP 5 Objects, Patterns & Practice Book (Matt Zandstra – Apress) – which changed my, php, life for the better.
In my previous comment I wasn’t moaning that ZF is thoroughly documented. I was expressing my anguish that it can take a long time to learn a framework. When I first started reading about frameworks i got moved by the hype thinking that i had been slogging away ‘coding the hard way’ whilst, all a long, a miraculous ‘easy way’ had been there for the taking…
“In 15 minutes, we go from scratch to complete weblog engine with comments, ajax, an ATOM feed…”etc http://rubyonrails.org/screencasts
The point is – its not as miraculous as the the hype says it is. Its still hard learning. But, as Vip says, once mastered it can do wonders.
Anyway – Vip puts it much better than i did:
“4. if you decide to use Frameworks, be ready for a long learning curve to master it, but it’s important to master it to make full use of it”
This is just my opinion:
My main issue with a lot of php frameworks is that they tend to force the developer to:
build an application from a framework, rather than building a framework for a needed application.
eg. if you needed a motorcycle, you wouldn’t build it from a car(where php is the engine).
Plus if you dont get under the hood of these frameworks, and understand it, you’ll essentially be a driver rather than a mechanic of a php framework.
If you are using the Zend framework, you need to be v aware of the structure, which to my eye may be overly complex for most projects. Getting rid of spagetti code and replacing it with spagetti structure, IMHO.
View the structure here:http://talks.php.net/presentations/slides/intro/zf.png
Recently Rasmus Lerdorf (creator of php), gave an interesting talk on the subject of php and its frameworks, it may give you a clearer insight into you use of php ?
Video of talk http://www.archive.org/details/simple_is_hard
Slides of talk http://talks.php.net/show/drupal08
Thank you for the very insightful comment. I tend to agree with your opinion. A lot of developers I feel put too much stock into frameworks.
Great replies above. I've been coding php for around 6 years now. I taught myself and like many that taught themselves, wrote the same queries and scripts over and over and over at first. Then you figure out how functions work and start making yourself a library of reusable code. With your personal library, you craft new applications quicker. From your libraries and hard learned lessons writing raw php. Personally, I wouldn't recommend anyone jump head first into frameworks with PHP. Mostly, because you need to understand how things work and code some sites in a procedural way to gain some necessary experience with PHP.
However, once you get far enough along, coding in a OO fashion using MVC is like a breath of fresh air. Especially for sites that a larger and more complex. Of course you can you craft your own framework, but why when there are tons of great frameworks and code libraries out there (that have large user bases). I'm using Kohana and it's cut down development time from my old way of developing considerably. I wouldn't trade my knocks I took from learning php though. The more you know about coding raw PHP before working with a framework, the far better off you will be and be able to customize a framework to your liking.
Tweetbacks
Trackbacks
Add your Comment!