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

PHP 7.3 && Laravel 5.7

PHP 7.3 && Laravel 5.7

A short summary of new things in PHP and its favorite framework.

E157a71a8b1585e6a33e2c6da01d4cac?s=128

Christian Leo-Pernold

October 23, 2018
Tweet

Transcript

  1. PHP 7.3 && Laravel 5.7 PHP 7.3 && Laravel 5.7

    1 / 21
  2. Christian Leo-Pernold @mazedlx https://github.com/mazedlx https://mazedlx.net 2 / 21

  3. Agenda Agenda Awesome Laravel 5.7 awesomeness! New PHP 7.3 features!

    3 / 21
  4. Laravel 5.7 Laravel 5.7 Email Verification Email Verification Dump Server

    Dump Server Improved Error Messages Improved Error Messages Beautiful Error Pages Beautiful Error Pages 4 / 21
  5. Email Verification Email Verification <?php <?php // create_users_table migration $table->timestamp('email_verified_at')->nullable();

    <?php <?php namespace namespace App App; use use Illuminate Illuminate\Notifications Notifications\Notifiable Notifiable; use use Illuminate Illuminate\Contracts Contracts\Auth Auth\MustVerifyEmail MustVerifyEmail; use use Illuminate Illuminate\Foundation Foundation\Auth Auth\User User as as Authenticatable Authenticatable; class class User User extends extends Authenticatable Authenticatable implements implements MustVerifyEmail MustVerifyEmail { use use Notifiable Notifiable; // ... } 5 / 21
  6. Email Verification Email Verification <?php <?php Auth::routes(['verify' => true true]);

    // This will add the following new routes // GET|HEAD email/resend // GET|HEAD email/verify // GET|HEAD email/verify/{id} 6 / 21
  7. Email Verification Email Verification <?php <?php Route::get('/profile', function function ()

    { // Only for verified users })->middleware('verified'); 7 / 21
  8. Dump Server Dump Server $ php artisan dump-server Laravel Var

    Dump Server ======================= [OK] Server listening on tcp://127.0.0.1:9912 // Quit the server with CONTROL-C 8 / 21
  9. Improved Error Messages Improved Error Messages <?php <?php $user =

    App\User::forst(); // 5.6: Method Illuminate\Database\Query\Builder::forst does not exist. // 5.7: Call to undefined method App\User::forst(); 9 / 21
  10. Beautiful Error Pages Beautiful Error Pages 10 / 21

  11. Beautiful Error Pages Beautiful Error Pages 11 / 21

  12. Beautiful Error Pages Beautiful Error Pages 12 / 21

  13. Beautiful Error Pages Beautiful Error Pages 13 / 21

  14. Beautiful Error Pages Beautiful Error Pages 403 404 419 -

    session has expired 429 - too many requests 500 503 Thank you, @steveschoger 14 / 21
  15. PHP 7.3 PHP 7.3 Array functions Array functions High Resolution

    Time High Resolution Time PCRE2 PCRE2 json_encode/json_decode Exceptions json_encode/json_decode Exceptions 15 / 21
  16. Array functions Array functions <?php <?php $arr = [ 'bob'

    => 1, 'jane' => 2, 'john' => 3 ]; var_dump(array_key_first($arr)); // bob var_dump(array_key_last($arr)); // john 16 / 21
  17. Array functions Array functions <?php <?php $arr = 'this is

    not an array!'; count($arr); // Warning count(): Parameter must be an array or an object that i if if (is_countable($arr)) { count($arr); } 17 / 21
  18. High Resolution Time High Resolution Time <?php <?php $time =

    hrtime($getAsNumber = false false); 18 / 21
  19. PCRE2 PCRE2 <?php <?php $matches = []; // throws compilation

    failed error preg_match('/[\w-.]+/', 'some -- words-and hyphens -', $matches); // ok preg_match('/[\w\-.]+/', 'some -- words-and hyphens -', $matches); 19 / 21
  20. json_encode / json_decode json_encode / json_decode throw exception on errors

    throw exception on errors <?php <?php try try { json_decode("{", $assoc = false false, $depth = 512, JSON_THROW_ON_ERROR); } catch catch (\JsonException $e) { echo echo $exception->getMessage(); // "Syntax error" } 20 / 21
  21. Slides can be found at speakerdeck.com/mazedlx 21 / 21

  22. None