Modern PHP

Modern PHP

Overview of tools and language concepts

3f2fb8bbcd44609346e1cc0c06d0a39b?s=128

Thomas Weinert

October 29, 2014
Tweet

Transcript

  1. MODERN PHP TOOLS & CONCEPTS @Thomas Weinert

  2. TOOLS

  3. IDES Eclipse Komodo Netbeans PHPStorm ...

  4. VCS GIT Subversion

  5. COLLABORATION Bitbucket GitHub Sourceforge

  6. GITLAB

  7. COMPOSER { "name": "carica/chip", "type": "library", "license": "MIT", "require": {

    "php": ">=5.4", "carica/firmata": "dev-master" }, "require-dev": { "phake/phake": "1.*" }, "autoload": { "psr-4": { "Carica\\Chip\\": "src\\" } } }
  8. PACKAGIST

  9. SATIS

  10. PHAR

  11. PHPUNIT Ide Integration Mockery Phake Prophecy

  12. BEHAT PHPSPEC

  13. PHING

  14. DEBUGGER Xdebug PHPDbg

  15. PROFILER Xdebug XHProf

  16. CODE QUALITY

  17. phpdepend phpmd phpcpd phploc

  18. PHP METRICS http://halleck45.github.io/PhpMetrics/

  19. SCRUNTINIZER CI https://scrutinizer-ci.com/

  20. SENSIOLABSINSIHGT https://insight.sensiolabs.com

  21. ENGINES PHP (Zend Engine) PHPNG HHVM

  22. ZEPHYR http://zephir-lang.com namespace MyLibrary; class Filter { public function alpha(string

    str) { char ch; string filtered = ""; for ch in str { if (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') { let filtered .= ch; } } return filtered; } }
  23. ZEPHYR http://zephir-lang.com $filter = new MyLibrary\Filter(); echo $filter->alpha("01he#l.lo?/1");

  24. PHP-CPP http://www.php-cpp.com/ Php::Value my_plus(Php::Parameters ¶meters) { return (int)parameters[0] + (int)parameters[1];

    }
  25. FEATURES

  26. NAMESPACES PSR-4

  27. ANONYMOUS FUNCTIONS $board ->activate() ->done( function () use ($board, $loop)

    { $pin = $board->pins[13]; $pin->mode = Firmata\Board::PIN_MODE_OUTPUT; $loop->setInterval( function () use ($pin) { $pin->digital = !$pin->digital; }, 1000 ); } );
  28. CALLABLE $_ = FluentDOM::create(); $_->formatOutput = true; echo $_( 'ul',

    ['class' => 'navigation'], $_('li', $_->cdata('FluentDOM')) );
  29. TRAITS namespace Carica\Io\Event\Loop { use Carica\Io\Event; trait Aggregation { private

    $_eventLoop = NULL; public function loop(Event\Loop $loop = NULL) { if (NULL !== $loop) { $this->_eventLoop = $loop; } elseif (NULL === $this->_eventLoop) { $this->_eventLoop = Factory::get(); } return $this->_eventLoop; } } }
  30. PASSWORD API password_hash() password_verify() password_needs_rehash() password_get_info()

  31. OPCACHE

  32. DATETIME / DATETIMEIMMUTABLE

  33. EXT/INTL

  34. MYSQLND

  35. SYNTAX

  36. ARRAYS function()[key] $array = [1, 2, 3]

  37. GENERATORS function xrange($start, $limit, $step = 1) { for ($i

    = $start; $i <= $limit; $i += $step) { yield $i; } }
  38. ::CLASS $object::CLASS CLASSNAME::CLASS

  39. CONSTANT EXPRESSION const SECONDS = self::DAYS * 86400

  40. VARIADICS function f($req, $opt = null, ...$params) { printf( '$req:

    %d; $opt: %d; number of params: %d'."\n", $req, $opt, count($params) ); } f(1); f(1, 2); f(1, 2, 3);
  41. ARGUMENT UNPACKING function add($a, $b, $c) { return $a +

    $b + $c; } $operators = [2, 3]; echo add(1, ...$operators);
  42. THANKS