Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bumping our Stack to PHP 5.5

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for Glen Mailer Glen Mailer
October 05, 2014

Bumping our Stack to PHP 5.5

A bit of a dev story, followed by a bit more of an ops story.

Here's what happened when we decided it was about time to get around to upgrading our PHP 5.3 app to something a bit more current.

Avatar for Glen Mailer

Glen Mailer

October 05, 2014
Tweet

More Decks by Glen Mailer

Other Decks in Technology

Transcript

  1. Upgrade a dev box Support 5.3 and 5.5 Pass all

    tests Upgrade 1 Test env Upgrade CI Upgrade Test & Staging Incrementally Upgrade Live
  2. Check for new function, fall back to old one if

    (function_exists('opcache_reset')) { opcache_reset(); } else { apc_clear_cache(); }
  3. “The PHP api will retain compatibility with APC, as will

    common configuration options, providing a drop in replacement.” APCu
  4. "Type-checked" function function inc($int) { if (!is_int($int)) { throw new

    InvalidArgumentException( 'Expected int, got: ' . $int ); } return $int + 1; }
  5. Unit test for type-checked function /** * @dataprovider provideIncInvalid */

    function testIncRejectsInvalid($a) { try { inc($a); $this->fail('Expected exception'); } catch (InvalidArgumentException $ex) {} } function provideIncInvalid() { return array( null, true, "string", array() ); }
  6. Upgrade a dev box
 Support 5.3 and 5.5
 Pass all

    tests
 Upgrade 1 Test env
 Upgrade CI
 Upgrade Test & Staging
 Incrementally Upgrade Live
  7. Upgrade a dev box
 Support 5.3 and 5.5
 Pass all

    tests
 Upgrade 1 Test env
 Upgrade CI
 Upgrade Test & Staging
 Incrementally Upgrade Live
  8. function barwell_store($key, $value) { $path = BARWELL_BASE . '/' .

    md5($key); file_put_contents( $path, '<?php return ' . var_export($value, 1) ); opcache_invalidate($path); } function barwell_fetch($key) { return include(BARWELL_BASE . '/' . md5($key)); }
  9. function barwell_store_obj($key, $value) { $path = BARWELL_BASE . '/' .

    md5($key); file_put_contents( $path, '<?php return unserialize("' . serialize($value) . '")' ); opcache_invalidate($path); }