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

Modern PHP, Standards, and Community

Ben Edmunds
September 29, 2016

Modern PHP, Standards, and Community

Learn how to structure and maintain a modern day PHP project using the latest standards. We'll walk through recent language improvements and how they will affect your day to day development. This will use code examples to give you in depth, real world examples of usage.

We'll also cover the latest community initiatives and standards including the PHPFIG along with the PSRs they have introduced.

Ben Edmunds

September 29, 2016
Tweet

More Decks by Ben Edmunds

Other Decks in Technology

Transcript

  1. Who is this guy? Ben Edmunds Open Source Author PHP

    Town Hall Podcast CTO at Mindfulware
  2. Errors try { //error thrown here } catch (Error $e)

    { die($e->getMessage()); } catch (Exception $e) { die($e->getMessage()); }
  3. Traits // grouping without // strict inheritance trait baseUser {

    function getName() { return ‘Jon Snow’; } }
  4. PDO

  5. PDO $stmt = $db->prepare(‘ SELECT * FROM users WHERE id=:id

    ’); $stmt->bindParam(‘:id’, $id); $stmt->execute();
  6. Scalar Types declare(strict_types=1); function addNums(float $a, float $b) { return

    $a + $b; } addNums(2, "1 week"); // Fatal error: Uncaught TypeError: Argument 2 passed to addNums() must be of the type float, string given
  7. Scalar Types function addNums(float $a, float $b) addNums(2, "1 week”);

    // Fatal error: Uncaught TypeError: Argument 2 passed to addNums() must be of the type float, string given
  8. Scalar Types function addNums($a, $b) : int { return $a

    + $b; } addNums(1.5, 1); // Fatal error: Uncaught TypeError: Return value of addNums() must be of the type integer, float returned
  9. Built-in Server $ php -S localhost:8000 PHP 5.7.0 Development Server

    started… Listening on localhost:8000 Document root is /home/ben/htdocs Press Ctrl-C to quit
  10. Unit Testing $ phpunit tests PHPUnit 3.3.17 by Sebastian Bergmann.

    Time: 0.01 seconds OK (1 tests, 1 assertions)
  11. Standards PSRs PSR-4: Autoloading PSR-1: Basic Coding Standards PSR-2: Coding

    Style Guide PSR-7: HTTP Message Interface PSR-6: Caching Interface PSR-3: Logger Interface