$30 off During Our Annual Pro Sale. View Details »

Por que PHP é a melhor coisa desde o pão fatiado

Por que PHP é a melhor coisa desde o pão fatiado

Palestra detalhando passado, presente e futuro da linguagem, com exemplos de código-fonte.

Er Galvão Abbott

June 08, 2019
Tweet

More Decks by Er Galvão Abbott

Other Decks in Programming

Transcript

  1. www.galvao.eti.br
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 1 / 29
    Photo by the Flour Advisory Bureau, UK
    php

    View Slide

  2. www.galvao.eti.br
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 2 / 29
    Photo by the Flour Advisory Bureau, UK
    php >

    View Slide

  3. www.galvao.eti.br
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 3 / 29
    Photo by the Flour Advisory Bureau, UK
    php >

    View Slide

  4. Presidente (2012 – 2017) da
    ABRAPHP – Associação Brasileira de Profissionais PHP
    Diretor da PHP Conference Brasil
    Evangelista e Contribuidor para a Linguagem
    Atua como Zend Framework Evangelist para o ZTeam, da Zend
    Embaixador Fedora LATAM
    Professor Convidado (Especialista) de Pós-Graduação (PR e SC)
    25+ anos desenvolvendo sistemas e aplicações com interface web
    20+ destes com PHP
    12+ com Zend Framework
    Palestrante em eventos nacionais e internacionais
    Professor de cursos presenciais e a distância
    Quem?!
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 4 / 29
    www.galvao.eti.br
    Por que PHP é a melhor coisa desde o pão fatiado
    www.galvao.eti.br

    View Slide

  5. Objetivo
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 5 / 29
    www.galvao.eti.br
    Expor as características, features, conceitos, etc… que fazem
    da linguagem uma das melhores opções para o mercado de
    desenvolvimento em geral e web em particular.
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  6. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 6 / 29
    www.galvao.eti.br
    Use código-fonte que você não entende completamente e
    prepare-se para ser julgado
    DISCLAIMER
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  7. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 7 / 29
    www.galvao.eti.br
    Use código-fonte que você não entende completamente e
    prepare-se para ser julgado pelo Rei Koala do Inferno.
    DISCLAIMER
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  8. ≃ 25 anos de Mercado
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 8 / 29
    www.galvao.eti.br
    1995
    “PHP 1”
    PHP 3
    1998
    2000
    2004
    2009
    PHP 4
    PHP 5
    5.3
    7.0
    7.1
    7.2
    7.3
    7.4
    8.0
    2015
    2016
    2017
    2018
    2019*
    2020*
    Você está aqui*(Espero...)
    Image by Vincent Pontier
    Os críticos da linguagem
    ainda estão aqui...
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  9. Versões 1 → 4
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 9 / 29
    www.galvao.eti.br
    Simplicidade > Complexidade
    Popularidade
    Aderência ao Mercado
    C → Perl → PHP
    v3 à nível internacional, v4 a nível nacional
    OO, SGBDs, XML...
    Cultura
    Criação do elePHPant
    Visão
    A linguagem se torna OSS
    Veia Corporativa
    Criação da Zend Technologies
    1995 → 2000
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  10. Versão 5.0
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 10 / 29
    www.galvao.eti.br
    A primeira versão verdadeiramente profissional
    Maturidade
    Inconsistências como no suporte a Oracle resolvidas
    OO e XML re-escritos
    Qualidade
    MySQLi, PDO (ext) , Exceptions, Classes Nativas em geral
    2004
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  11. Versão 5.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 11 / 29
    www.galvao.eti.br
    O maior salto entre a versão 5.0 e a 7.0
    Maturidade
    Namespaces → Composer, Funções Anônimas, PHAR
    Obsolescência de Register Globals e Safe Mode
    password_hash, bcrypt!
    Comunidade! Evento!
    GUs, PHP Conference Brasil, Eventos OSS
    2009
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  12. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 12 / 29
    www.galvao.eti.br
    Performance
    Inovação
    Scalar Type Hints, Return Type declarations
    2015 → 2019
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  13. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 13 / 29
    www.galvao.eti.br
    2015 → 2019
    session_start([
    'name' => bin2hex(random_bytes(8)),
    'referer_check' => 'foo*',
    'use_only_cookies' => 1,
    'use_trans_sid' => 0,
    'cookie_httponly' => 1,
    'cookie_secure' => 1,
    'cookie_lifetime' => 0,
    'save_handler' => 'files',
    'save_path' => __DIR__ . '/../data/session',
    'use_strict_mode' => 1,
    'sid_length' => 128,
    ]);
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  14. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 14 / 29
    www.galvao.eti.br
    2015 → 2019
    $rcvdObject = unserialize($serializedObject,
    ['allowed_classes' => TRUE]
    );
    $rcvdObject = unserialize($serializedObject,
    ['allowed_classes' => FALSE]
    );
    $rcvdObject = unserialize($serializedObject,
    ['allowed_classes' => ['Foo', 'Bar', 'Baz']]
    );
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  15. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 15 / 29
    www.galvao.eti.br
    2015 → 2019
    $hiker = new class (42, 'Zaphod Beeblebrox') {
    private $id;
    private $name;
    public function __construct($id, $name)
    {
    $this->id = $id;
    $this->name = $name;
    }
    };
    var_dump($hiker);
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  16. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 16 / 29
    www.galvao.eti.br
    2015 → 2019
    class Hiker
    {
    private $id;
    private $name;
    public function __construct(int $id, string $name)
    {
    $this->id = $id;
    $this->name = $name;
    }
    public function getId(): int
    {
    return $this->id;
    }
    }
    $zaphod = new Hiker(42, 'Zaphod Beeblebrox');
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  17. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 17 / 29
    www.galvao.eti.br
    2015 → 2019
    session_start([
    'gc_probability' => 0,
    ]);
    session_gc();
    session_destroy();
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  18. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 18 / 29
    www.galvao.eti.br
    2015 → 2019
    function hitchHike($towel = NULL)
    {
    if (func_num_args() > 1) {
    throw new ArgumentCountError('Too many arguments!');
    }
    if ($towel === NULL) {
    throw new Exception('It’s dangerous out there!');
    }
    }
    try {
    hitchHike(NULL, 'foo');
    } catch (ArgumentCountError | Exception $e) {
    printf('> %s' . PHP_EOL, $e->getMessage());
    }
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  19. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 19 / 29
    www.galvao.eti.br
    2015 → 2019
    class Foo
    {
    public const BAR = 2;
    private const BAZ = 4;
    }
    printf('%d - %d' . PHP_EOL, Foo::BAR, Foo::BAZ);
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  20. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 20 / 29
    www.galvao.eti.br
    2015 → 2019
    function increment(int &$num): void
    {
    $num++;
    return;
    }
    $x = 1;
    increment($x);
    printf('X equals to %d' . PHP_EOL, $x);
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  21. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 21 / 29
    www.galvao.eti.br
    2015 → 2019
    $key = random_bytes(32);
    $nonce = random_bytes(24);
    $message = 'Libsodium goes way beyond simple encryption!';
    $cipherText = sodium_crypto_secretbox($message, $nonce, $key);
    $plainText = sodium_crypto_secretbox_open($cipherText, $nonce, $key);
    var_dump(bin2hex($cipherText), $plainText);
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  22. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 22 / 29
    www.galvao.eti.br
    2015 → 2019
    $submittedPwd = 'a damn fine pass';
    $hashedPwd = password_hash($submittedPwd, PASSWORD_ARGON2ID);
    var_dump($hashedPwd);
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  23. 7.0 → 7.3
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 23 / 29
    www.galvao.eti.br
    2015 → 2019
    $dsn = 'pgsql:host=foo;dbname=bar';
    $dbh = new PDO($dsn, 'baz', 'quux');
    $id = 2;
    $sql = 'SELECT * FROM server WHERE id = :id';
    $sth = $dbh->prepare($sql);
    $sth->bindValue(':id', $id, PDO::PARAM_INT);
    var_dump($sth->debugDumpParams());
    $sth->execute();
    while($record = $sth->fetchObject()) {
    var_dump($record);
    }
    $dbh = NULL;
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  24. Versão 7.4
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 24 / 29
    www.galvao.eti.br
    2019*
    Por que PHP é a melhor coisa desde o pão fatiado
    Arrow Functions
    Preloading de funções e classes
    FFI – Foreign Function Interface
    Typed Properties

    View Slide

  25. Versão 8.0
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 25 / 29
    www.galvao.eti.br
    2020*
    Por que PHP é a melhor coisa desde o pão fatiado
    JIT

    View Slide

  26. Versão 8.0
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 26 / 29
    www.galvao.eti.br
    2020*
    Por que PHP é a melhor coisa desde o pão fatiado
    JIT

    View Slide

  27. Versão 8.0
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 27 / 29
    www.galvao.eti.br
    2020*
    Por que PHP é a melhor coisa desde o pão fatiado
    JIT

    View Slide

  28. Muito obrigado!
    CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 6/8/19 - 28 / 29
    www.galvao.eti.br
    ? Dúvidas?
    ↓ Críticas?
    ↑ Elogios?!
    Por que PHP é a melhor coisa desde o pão fatiado

    View Slide

  29. 14ª
    Edição
    7.500+
    Participantes
    www.phpconference.com.br
    550+
    Palestras
    980+
    Horas de
    Conteúdo

    View Slide