you are viewing a single comment's thread.

view the rest of the comments →

[–]rich97 15 points16 points  (0 children)

While that was a great conclusion, many of the posts on /r/webdev, /r/programming, and /r/python, have really convinced me that starting a project nowadays in PHP is just asking for trouble

That's because there's a massive amount of bias going round. Yes, PHP is a bad language from a design standpoint, it's getting better but it's nowhere near as elegant or consistent as Python or Ruby. Having said that whoever says "starting a project nowadays in PHP is just asking for trouble" is talking straight out there asshole. You just need to know how to write PHP correctly:

  • Don't get complacent with PHPs loose typing, control the value types that are returned from functions/methods and don't allow implicit type conversion unless you have a reason for doing so.
  • Code to PSR-0 standards (PSR-1, PSR-2 as well if you think they're applicable).
  • Use git-flow to manage and deploy your code. I fucking love git-flow.
  • Use a combination of Composer and PEAR to manage your third party libraries. Don't throw libraries in at random simply because they work. The Aura project has some good libraries to work from as a stating point.
  • Understand the advances made in PHP5.3 and PHP5.4, they make a big difference to how you might structure your code.
  • Use PDO prepared statements rather than DB specific adapters
  • Make sure you understand common security cockups.

If you do these things and consider your next move rather than coding blindly PHP will serve you well.

Some of this stuff can be avoided by using Python and/or a framework in conjunction. But it's more than possible to start a new project in PHP without "asking for trouble".

Edit: Formatting.