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

Outside The Bubble

Outside The Bubble

What happened outside of the WordPress community in the PHP community at large

Tom J Nowell

July 14, 2013
Tweet

More Decks by Tom J Nowell

Other Decks in Technology

Transcript

  1. Massive Performance Increases PHP 5.3 significantly faster than 5.2 PHP

    5.4 up to 2x as fast in some benchmarks No code changes required
  2. PSR-0 PSR-1 and PSR-2 Standards for PHP code: • Standard

    code style • Standard auto loaders & class conventions • Standard logger interfaces • Amongst others..
  3. Lambdas & Closures // Lambdas add_action( 'the_content', function( $content ){

    return $content.'Final Note'; }); // Closures $note = 'Final Note'; add_action( 'the_content', function($content) use($note) { return $content.$note; }); // anonymous functions $func = function( $content ) { return $content.'the end'; }; add_action( 'the_content', $func );
  4. Queues, Stacks, Sets, PriorityQueues, Heaps & other SPL containers Special

    containers with performance and memory advantages over standard arrays
  5. Replaced by PDO, MySQLi & ORMs e.g. Doctrine, Idiorm etc

    WordPress hasn't moved to support these and breaks in PHP 5.5
  6. PHP Mess Detector Takes a given PHP source code base

    and look for several potential problems within that source. These problems can be things like: • Possible bugs • Suboptimal code • Overcomplicated expressions • Unused parameters, methods, properties
  7. SCheck & Facebook PHP tools • Catch common mistakes such

    as: function add_hash( $color ) { return '#'.$colour; } addhash(); // missing '_' • Generate databases describing your code structure for analysis • View codebases in visual tools with Google Maps style panning and zoom, and search for functions and objects
  8. phantm Static analyser to check type in PHP code amongst

    other things $dict = array(); $dict['en'] = array(); $dict['en']['fr'] = 'Bonjour'; $dict['en']['de'] = 'Hallo'; $dist['en']['it'] = 'Ciao'; $dict['en']['sp'] = 'Hola'; <input>:7 Notice: Type mismatch: expected: Array[...], found: Top $dist['en']['it'] = 'Ciao';
  9. Goutte A web client/scraping library require_once '/path/to/goutte.phar'; use Goutte\Client; $client

    = new Client(); $crawler = $client->request( 'GET', 'http://www.symfony-project.org/' ); $link = $crawler->selectLink('Plugins')->link(); $crawler = $client->click($link); $nodes = $crawler->filter('.error_list'); if ($nodes->count()){ die(sprintf("Authentication error: %s\n", $nodes->text())); }
  10. Assetic Asset management on steroids • Handles all assets, js/css/images/less/sass/etc

    • Generic filter system for compilation/compression/URL handling amongst other things • Handles Caching & filesystem searches
  11. Klein Superfast URL Router Library <?php require_once __DIR__ . '/vendor/autoload.php';

    $klein = new \Klein\Klein(); $klein->respond('GET', '/hello-world', function () { return 'Hello World!'; }); $klein->dispatch();
  12. Dispatch A PHP 5.3 Micro framework <?php require('../src/dispatch.php'); config('site.router', 'index.php');

    get('/users', function () { echo "listing users..."; }); // get route for index get('/index', function () { echo "hello, world!\n"; });
  13. Twig Super fast templating engine <!DOCTYPE html> <html> <head> <title>My

    Webpage</title> </head> <body> <ul id="navigation"> {% for item in navigation %} <li><a href="{{ item.href }}">{{ item.caption }}</a></li> {% endfor %} </ul> <h1>My Webpage</h1> {{ a_variable }} </body> </html>