Slide 1

Slide 1 text

The Latest in PHP June 2019 Edition

Slide 2

Slide 2 text

Presented by Chris Gmyr @cmgmyr

Slide 3

Slide 3 text

PHP Supported Versions 4 7.1 Security Only until Dec 1, 2019 4 7.2 & 7.3 Active Development 4 7.4 is underway (~Nov 2019, last 7 branch) 4 8.0 in 2020 More Info: 4 http://php.net/supported-versions.php

Slide 4

Slide 4 text

PHP Releases 4 7.1.[29-30] 4 7.2.[18-19] 4 7.3.[5-6] 4 7.4.0 Alpha 1! 7.1.* - 7.3.* have Security and Bug fixes More Info: 4 http://php.net/ChangeLog-7.php

Slide 5

Slide 5 text

PHP RFC: Arrow Functions 2.0 (Implemented in 7.4) // before function array_values_from_keys($arr, $keys) { return array_map(function ($x) use ($arr) { return $arr[$x]; }, $keys); } // after function array_values_from_keys($arr, $keys) { return array_map(fn($x) => $arr[$x], $keys); } https://wiki.php.net/rfc/arrow_functions_v2

Slide 6

Slide 6 text

PHP RFC: Spread Operator in Array Expression (Implemented in 7.4) PHP has already supported argument unpacking (AKA spread operator) since 5.6. This RFC proposes to bring this feature to array expression. $parts = ['apple', 'pear']; $fruits = ['banana', 'orange', ...$parts, 'watermelon']; // ['banana', 'orange', 'apple', 'pear', 'watermelon']; https://wiki.php.net/rfc/spread_operator_for_array

Slide 7

Slide 7 text

PHP RFC: Nullsafe Calls (Draft) A new operator would be added to the language: ?->. Calling $obj?->foo(..) behaves identically to $obj->foo(..) if $obj is not null. If $obj is null, then it returns null. function f($o) { return $o?->mayFail1()?->mayFail2()?->mayFail3()?->mayFail4(); } https://wiki.php.net/rfc/nullsafe_calls

Slide 8

Slide 8 text

PHP RFC: Alternative "use" syntax for Closures (Under Discussion) https://wiki.php.net/rfc/alternative-closure-use- syntax

Slide 9

Slide 9 text

PHP RFC: Alternative "use" syntax for Closures // before... $closure = function ( ArgumentType $argument1, ArgumentType $argument2, ArgumentType $argument3, ArgumentType $argument4 ) use ( $importVariable1, &$importVariable2, $importVariable3, &$importVariable4 ): ReturnType { // ... };

Slide 10

Slide 10 text

PHP RFC: Alternative "use" syntax for Closures // after... $closure = function ( ArgumentType $argument1, ArgumentType $argument2, ArgumentType $argument3, ArgumentType $argument4 ): ReturnType { use $importVariable1, &$importVariable2; use $importVariable3, &$importVariable4; // ... };

Slide 11

Slide 11 text

PHP Quick Tip

Slide 12

Slide 12 text

levenshtein() Calculate Levenshtein distance between two strings $str1 = "apple"; $str2 = "appplee"; echo levenshtein($str1, $str2); // 2 https://www.php.net/manual/en/ function.levenshtein.php

Slide 13

Slide 13 text

// input misspelled word $input = 'carrrot'; // array of words to check against $words = array('apple','pineapple','banana','orange', 'radish','carrot','pea','bean','potato'); // no shortest distance found, yet $shortest = -1; // loop through words to find the closest...

Slide 14

Slide 14 text

foreach ($words as $word) { // calculate the distance between the input word, and the current word $lev = levenshtein($input, $word); // check for an exact match if ($lev == 0) { $closest = $word; $shortest = 0; break; } // if this distance is less than the next found shortest // distance, OR if a next shortest word has not yet been found if ($lev <= $shortest || $shortest < 0) { // set the closest match, and shortest distance $closest = $word; $shortest = $lev; } }

Slide 15

Slide 15 text

echo "Input word: $input\n"; if ($shortest == 0) { echo "Exact match found: $closest\n"; } else { echo "Did you mean: $closest?\n"; } --- Input word: carrrot Did you mean: carrot?

Slide 16

Slide 16 text

Latest Versions 4 Laravel: 5.8.24 4 Symfony: 4.3.1 4 Drupal: 8.6.17 4 PHPStorm: 2019.1.3 4 VSCode: 1.35

Slide 17

Slide 17 text

PHP Conferences - July Laracon VII July 24–25, New York, New York https://laracon.us

Slide 18

Slide 18 text

PHP Conferences - September SymfonyLive Berlin 2019 September 24–27, Berlin, Germany http://berlin2019.live.symfony.com Cascadia PHP September 19–21, Portland, OR https://cascadiaphp.com

Slide 19

Slide 19 text

Nomad PHP US: Double Loop: TDD & BDD Done Right presented by Jessica Mauerhan June 20, 2019 at 06:00pm PDT UK: The Dark Corners of the SPL presented by Omni Adams June 20, 2019 at 11:00am PDT https://nomadphp.com/

Slide 20

Slide 20 text

Open Call for Papers PHPCon Poland 2019 CfP Deadline: July 10, 2019 November 15–17, Szczyrk, Poland https://2019.phpcon.pl PHP.Barcelona Conferenence 2019 CfP Deadline: September 30th, 2019 November 12–13, Barcelona, Spain https://php.barcelona

Slide 21

Slide 21 text

Upcoming regional events All Things Open Oct 13-15, 2019 http://allthingsopen.org Early bird going on now for $99!

Slide 22

Slide 22 text

Notable News & Articles 4 PHP Versions Stats - 2019.1 Edition 4 Package: composer-git-hooks 4 Package: prestissimo (composer plugin) 4 Taylor Otwell: Laravel Live QA 4 GitHub Actions for PHP Developers 4 A Look At PHP’s isset() 4 Structuring the Docker setup for PHP Projects

Slide 23

Slide 23 text

Next Month @ TrianglePHP TDB Presented By YOU?!?! Thursday, July 18, 6pm @ Atlantic BT Need an Idea? 4 Testing 4 Security 4 Performance 4 Git

Slide 24

Slide 24 text

Have a Job/Need a Job Who's hiring? Who's looking? What are you looking for?

Slide 25

Slide 25 text

Tonight @ TrianglePHP Simple DevOps with Laravel's Forge & Envoyer Presented By - Chris Gmyr Thank you to Atlantic BT for hosting and refreshments!