24 years of PHP in 24 minutes

PHP: where did it come from and why is it so ubiquitous?

Community Question:

Tom Newby @tomnewbyau

About Me

  • Started writing PHP back as a teenager
  • PiggyBike & DingoPM
  • Co-founder & Software Developer @ HyraIQ
  • We're reinventing lease negotiation for retail and commercial landlords
  • Symfony 4, Remote - We're hiring 😉

Community Question

I've never used PHP. I'm a late career changer.


One of my biggest frustrations is not understanding why I am using a framework. What problem is it solving? More importantly: How did things used to be?

 

I would like a history lesson of the web and PHPs role in the proceedings. What PHP started out doing. What it does now.

 

This will make me more effective when I 'encounter it' in the wild.

Tonight's Outline

  • Language origins and evolution
  • Ubiquity and mass adoption

1993

  • We've got internet, kinda
  • Static HTML + executables ¯\_(ツ)_/¯ (lolwat security)
  • Spec was formed for Common Gateway Interface

1994/5

  • Rasmus Lerdorf creates "PHP Tools"
  • Collection of Perl CGI scripts
  • Page counter for online resume

I don't know how to stop it, there was never any intent to write a programming language [...] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way.

Rasmus Lerdorf, 2003

Naming

  • Personal Homepage Construction Kit 
  • Personal Home Page Tools (PHP Tools)
  • Personal Home Page / Forms Interpreter (PHP/FI)

Features

  • Re-written in C
  • Simple programming language (control flow)
  • User defined functions
  • 300+ functions to do what you need (strpos etc.)
  • Form intepretation
  • Database & filesystem interaction

But it was popular

  • It did simple things easily
  • 1% of domains in '98

Example Code PHP/FI 1.x

<!--include /text/header.html-->

<!--getenv HTTP_USER_AGENT-->
<!--ifsubstr $exec_result Mozilla-->
  Hey, you are using Netscape!<p>
<!--endif-->

<!--sql database select * from table where user='$username'-->
<!--ifless $numentries 1-->
  Sorry, that record does not exist<p>
<!--endif exit-->
  Welcome <!--$user-->!<p>
  You have <!--$index:0--> credits left in your account.<p>

<!--include /text/footer.html-->

PHP 3.0

  • Released in 1998
  • Andi Gutmans and Zeev Suraski
  • Rewrote the parser in collaboration with Rasmus
  • Now, with objects!
  • Now multiple core contributors!
  • Works on Windows + Mac servers
  • Tastes closer to Modern PHP

PHP 4

  • Released 2000
  • Zeev and Andi formed Zend and rewrote PHP core, again
  • Modularity and performance
  • Additional language features, HTTP session, output buffering

PHP 5

  • Released in 2004
  • Powered by Zend Engine 2
  • Huge change to object system
  • Returning handles to objects
  • Also, Exceptions!

PHP 6

  • Dev started in 2005, but later abandoned
  • Unicode support
  • Other language features (namespaces)
  • Backported to 5.x

PHP 7

  • Released 2015 - decade after 5.0
  • Another fork, phpng
  • Performance bump (2x speed - 1/2 memory)
  • So many language features
  • Scalar type declaration, return types, anonymous classes
  • Deprecations + BC break
  • Tastes a bit like Java with $

Genesis Summary

  • Language & design was born out of necessity
  • No formal spec until 2014
  • Internals have been rewritten numerous times
  • Now a more robust object & type system
  • Lots of stuff added before objects!
  • ~250 core contributors to PHP7

Ubiquity?

  • Today, ~80% of domains are powered by PHP

Why is it so ubiquitous?

  • An adaptable language
  • Shared hosting lowered barrier to entry
  • Framework boom
  • A vibrant community that works together, innovates

An adaptable language

  • Procedural
  • OOP
  • Functional*
  • Single page
  • Multi page
  • Frameworks
  • Web applications
  • Content sites
  • Command line tools
  • No types
  • Partial typing
  • Strict(ish) typing

Shared hosting lowered barrier to entry

  • Shared hosting provided LAMP stacks for $X/mth
  • No shell, but FTP
  • Economic drivers => hosting, agencies + plugin dev
  • Simple and feasible for small biz & forums to have a presence, community or transact on the internet

Framework Boom

  • CMS' like Drupal, Joomla and Wordpress
  • Forums like phpBB
  • eCommerce like Magento, PrestaShop, WooCommerce

But these were built:

  • Many starting in PHP 4
  • Procedural style
  • Without OOP, types or namespaces
  • Dependency management

 

There was limited scope for code reuse

Framework communities were insular

Community Cooperation

  • "Go PHP 5" initiative saw PHP ^5.x adoption go from 5% (2007) to >50% (2008)
  • Namespaces + Composer (2012) => Code re-use
  • A combined community can achieve better things
  • Let's solve problems together (PHP-FIG):
    • Dependency injection (PSR-11)
    • Logging (PSR-3, Monolog)
    • Autoloading (PSR-4)

A community that innovates

  • Zend Engine 1 & 2, phpng
  • HipHop for PHP, HHVM, Hack
  • Serverless PHP with Bref
  • Async PHP => AmPHP, ReactPHP

On ubiquity

  • An adaptable language
  • Shared hosting lowered barrier to entry
  • Framework boom
  • A vibrant community that works together, innovates

Thanks for listening!

Go forth and contribute to the community

 

Twitter: @tomnewbyau

Made with Slides.com