DEV Community

Discussion on: Pitch me on PHP

Collapse
 
jacekandrzejewski profile image
Jacek Andrzejewski

Pros:

  • gradual typing (you can ignore types and add them over time later)
  • std library with many useful functions that I wish c/c++ had this easy to use
  • evolves pretty fast
  • very fast (vanilla php+nginx can respond with hello world in 4ms, going with Laravel under 50ms doesn't require much work)
  • steals good syntax from other languages
  • has magic and metaprogramming (read up on __get, __invoke and "Variable variables")
  • good docs
  • great dependency manager (composer)
  • amazing tooling (code style, static analysis and amazing automated refactoring where you can migrate big project between frameworks in a week [Rector])
  • multi-paradigm, so you can be OOP or functional (kind of)
  • has traits (like mixins

Cons:

  • magic and metaprogramming can make code extremely hard to read and debug [as example you can call function by "functionname"(args)]
  • default type casting
  • legacy code is so bad that satan laughs whenever someone has to work on it (or maybe he wrote it)
  • sometimes inconsistent, sometimes consistent
  • quite a bit of legacy syntax
  • pure php tutorials online are mostly outdated by 10 years at least