2

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?

4 Answers4

2

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)
yannis
  • 39,547
  • 40
  • 183
  • 216
Matt
  • 151
  • 3
  • 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](http://programmers.stackexchange.com/privileges/comment). 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 Jan 15 '12 at 08:14
0

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.

Gary Willoughby
  • 2,067
  • 16
  • 19
0

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.

Demian Brecht
  • 17,555
  • 1
  • 47
  • 81
0

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.

bunglestink
  • 2,262
  • 16
  • 26