Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
When should I start learning a PHP Framework

I am an absolute beginner programmer. I've got lots of theoretical understanding from university a decade ago but no practical experience. I want to remedy that with a hobby project that would be similar to a real-world sellable web app. I've chosen PHP in order to avoid OS specifics, build process, etc.

Should I start out using a framework, or coding everything by hand? What would the benefits of using a framework be?

I have briefly looked at PHP Code Ignition and it does a good job of praising its own benefits. I am sure that is true for an experienced developer, but does it also apply to a beginner?

share|improve this question
add comment

marked as duplicate by Mark Trapp Jan 14 '12 at 23:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers

I'd strongly recommend getting started with a framework, once you're comfortable with the basics. This means that you should probably work a few examples from a book first, and get a good grounding in object oriented practices and relational databases. Once you've hacked about a bit, move on to frameworks as soon as possible.

All frameworks I can think of in the PHP world are strongly object oriented, so provided you're comfortable with that, you should be in a good place to make a start. The advantage with using a framework is that you can learn best practices, which is especially important in the PHP ecosystem - as a PHP programmer myself I can tell you that there are a number of poor practices that are passed around on blogs etc, and it will pay to learn from the correct sources.

I'd suggest learning from a micro framework like Silex to begin with - this is placed somewhere between the middle of straight PHP and full blown frameworks like Symfony, and you'll be introduced to the MVC paradigm as well as great other constructs such as the use of ORMs and lambda functions.

And to answer the second part of your question, the main benefits are that:

  1. the code is highly tested,
  2. it introduces best practices,
  3. most frameworks encourage test driven development, which helps you output reliable code, 4. many frameworks emphasise separation of concerns, making applications scalable and easier to debug,
  4. most frameworks have drop in plugins or libraries for doing all sorts of wonderful things, which can really speed up development, and
  5. many frameworks will generate code for you - you give them a database definition and they will generate all access code (CRUD)
share|improve this answer
    
And to answer the second part of your question, the main benefits are that 1) the code is highly tested, 2) it introduces best practices, 3) most frameworks encourage test driven development, which helps you output reliable code, 4) many frameworks emphasise separation of concerns, making applications scalable and easier to debug, 5) most frameworks have drop in plugins or libraries for doing all sorts of wonderful things, which can really speed up development, and 6) many frameworks will generate code for you - you give them a database definition and they will generate all access code (CRUD) –  Matt Jan 14 '12 at 23:44
    
Hi Matt, I edited your answer and included the above comment. Please note that you can do that yourself, comments are only supposed to be about asking for clarifications. If at any point you want to update you posts, just edit them. Also, if asked for clarifications, don't respond in comments, again update your post (if you feel the request for clarification had merit) –  Yannis Rizos Jan 15 '12 at 8:14
add comment

You need to buy a good book on web application programming and code and run the examples contained within. There is no better way of learning PHP.

share|improve this answer
add comment

I'd strongly suggest using (and learning from) a framework. Try to choose one that has a decent community behind it. When I was using PHP, I found that CodeIgniter and Yii were both fairly strong. The good thing about using a framework, in anyone's situation (whether yours or a seasoned vet), is that you can learn from people with more experience than you. If they don't have more experience, then you can gain insight into someone else's thinking and different methods of solving a specific task.

If you start writing your own framework, not only do you have to worry about running the risk of having incorrect solutions, but about teaching yourself (and buying into) incorrect or inefficient ways of doing things.

Of course, using someone else's framework, you could also learn someone else's mistakes and bad practices ;) Upside is, you won't have to worry about implementing the plumbing yourself.

share|improve this answer
add comment

If you are trying to learn PHP sufficiently on its own, a framework can actually make things more difficult. Yes, a framework will get you use to using certain patterns, but as a beginner, it can be difficult to separate learning PHP from learning the particular framework.

I would suggest learning PHP itself, even just on a trivial app, before diving right into a framework. After having a solid feel for PHP, then it will be easier to choose a framework that makes since for you. Without ever doing things the manual way, many of the benefits a framework provides may obfuscate what you are trying to accomplish.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.