Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. Small super abridged history lesson:
  2.  
  3. PHP used to be used largely for slapping together quick and dirty pages that shamelessly mixed presentation with business logic. Throw together a `contact.php` page with the PHP script at the top and the HTML at the bottom, and call it a day. Repeat for `login.php` and `cart.php` etc etc. Security practices had a lot of footguns.
  4.  
  5. A website had dozens of these entry point scripts. Lots of code duplication between them as well. Very little (if any) thought was put into more maintainable, testable architectures. It was shotgun programming at its finest. One of PHP's strengths is also its biggest weakness - it's easy enough for just about anyone to piece something together, but develop really bad habits doing it.
  6.  
  7. Later on, people realize there are lots of common patterns that can be solved by using frameworks to abstract them away and provide reusable solutions to them. But these frameworks were primitive at best. They had proprietary class loading systems and tightly coupled "MVC" architectures.
  8.  
  9. Then there's fucking WordPress - an attempt to make building sites easy with a thoughtless, throw shit at the wall until it sticks "architecture" and convoluted global API that does all this gnarly global state mutation behind the scenes. It has a funky DBAL with a funky API, and a clunky, inefficient EAV storage pattern where everything is either a `post` or meta data for a post. Relational data? Pffffff. WordPress is the Fischer-Price of web frameworks and it ends up normalizing and spreading really, really bad coding practices. It basically proliferates the idea that PHP is shit to work with and encourages novices to write shit software.
  10.  
  11. Fast forward to about PHP 5.3 and things start to change. Autoloading and namespaces, and some PSR standards allow for proper code importing. Composer comes along and does what `pip` and `gem` do. PHP finally has the language and tooling support needed to do proper application architecture with it (the same kind you would see in Rails or Django), and easily adopt modern patterns like front controller routing. Frameworks have yet to really adopt this in earnest though.
  12.  
  13. Then Laravel hits the scene, which was really the first full service framework to really adopt modern PHP features. Microframeworks like Slim and Silex also gain popularity, and in conjunction with Composer, make it dead simple to design and architect your own web application by assembling a huge library of third party components to suit your needs. Combined with PSR-0/4 autoloading, you had a *standard* way to do code importing, making everything easy and seamless.
  14.  
  15. So now the only thing the detractors have left is bitching about the standard library's somewhat inconsistent function argument ordering, and a few oddities and quirks here and there. But these are insignificant in the grand scheme of things.
  16.  
  17. The bottom line is this: PHP lets you architect clean, testable, well designed applications like any other language (with or without a framework). It lets you develop and easily import reusable code modules, just like any other language. It has a fairly robust (but not perfect) OO model, giving you many advantages of a nominal type system. PHP 7 also introduced some primitive types so you can build more strict applications to your liking, and offering better static analysis support for IDEs. Oh, and it does all this without a manual compile step, so you can rapidly iterate on and debug your application.
  18.  
  19. So in short, most of the shitting people do on PHP is habitual legacy crap from people who haven't touched the language in years and are honestly unqualified to talk about it, or from people who just don't like the syntax (a matter of preference that is inconsequential in the long run).
  20.  
  21. Sadly though, PHP cannot seem to shake its reputation, and from my experience, it *has* hurt job opportunities and earning potential. I had to switch to UI development since everyone needs UI devs, regardless of backend tech stack.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement