Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PHP Middleware - O que são? Onde vivem? O que fazem?

326 views

Published on

Talk sobre middleware realizada na The Dev Conference 2018.

Com a aprovação da PSR-7 e PSR-15 começou a chover frameworks e microframeworks que fornece suporte a middlewares. Mas o que são? Onde vivem? O que fazem? Essas e outras perguntas serão respondidas nessa apresentação!


Link do exemplo:
https://github.com/andersonluciano/api-middlewares-talk

Link Rest Hero:
https://github.com/andersonluciano/rest-hero

  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

PHP Middleware - O que são? Onde vivem? O que fazem?

  1. 1. Globalcode – Open4education Arquitetura PHP PHP Middleware, o que são? Onde vivem? O que fazem?
  2. 2. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? Anderson Luciano Desenvolvedor Web andersonluciano.me @AndersonLuciano andersonluciano.dev@gmail.com github.com/andersonluciano
  3. 3. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? https://www.php-fig.orgPHP Framework Interop Group!
  4. 4. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • PSR-7: HTTP message interfaces • Requests & Responses • Tratando a web com seu devido respeito • Baseado nas: • RFC 7230 • (Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing) • RFC 7231 • Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content • RFC 3986 • Uniform Resource Identifier (URI): Generic Syntax
  5. 5. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • PSR-7: HTTP message interfaces $request = $request ->withMethod('OPTIONS') ->withRequestTarget('*') ->withUri(new Uri('https://example.org/')); $request->getMethod(); $body = $request->parsedBody();
  6. 6. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • PSR-15: HTTP Server Request Handlers • Processa a requisição e produz uma resposta • Middleware em PHP • Utilizam a Message Interface (PSR-7)
  7. 7. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • PSR-15: HTTP Server Request Handlers interface MiddlewareInterface { /** * Process an incoming server request * * Processes an incoming server request in order to produce a response. * If unable to produce the response itself, it may delegate to the provided * request handler to do so. */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface; }
  8. 8. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • Middleware - O que são? • Desde 1980 - SO’s, Integrações entre sistemas, etc... • Interoperabilidade entre softwares • No PHP • HTTP Server Request Handlers • Manipuladores de requisições HTTP
  9. 9. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são?
  10. 10. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são?
  11. 11. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são?
  12. 12. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são?
  13. 13. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são?
  14. 14. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são?
  15. 15. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são? BodyParams, Auth, DatabaseHandler, Routing, UrlHelper [...] ResponseFormatter
  16. 16. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • O que são? BodyParams, Auth, DatabaseHandler, Routing, UrlHelper [...] ResponseFormatter
  17. 17. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • Middleware - Onde vivem? • Camadas do sistema! • Diferenças do Padrão MVC
  18. 18. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • Onde vivem?
  19. 19. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • Onde vivem?
  20. 20. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • Onde vivem? • Operam dentro da requisição • São organizados no formato de pilha
  21. 21. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem?
  22. 22. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • Middleware - O que fazem? • Centralizam responsabilidades do processo • Privacidade, conversões, permissões, formatações, logs, gatilhos, [...] • O céu é o limite! • Permitem a interoperabilidade das aplicações • if (forem bem implementados)
  23. 23. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? • 3 Dicas básica - Sempre faça uma das 3 • Retorne uma Response • Baseada na ResponseInterface (PSR-7) • Chame a próxima camada • Retorne uma Exceção
  24. 24. Globalcode – Open4education • Middleware - O que não fazer! • Nunca terminarás a execução do programa em um middleware. • Nunca alterarás o conteúdo da response. • Nunca deixarás de repassar a requisição para a camada seguinte. • Nunca desvirtuarás seu uso • echo "<h1>Acesso Negado</h1>";exit; PHP Middleware, o que são? Onde vivem? O que fazem?
  25. 25. Globalcode – Open4education • Alguns Frameworks PHP Middleware, o que são? Onde vivem? O que fazem?
  26. 26. Globalcode – Open4education Exemplo - Zend Expressive https://github.com/andersonluciano/api-middlewares-talk PHP Middleware, o que são? Onde vivem? O que fazem?
  27. 27. Globalcode – Open4education PHP Middleware, o que são? Onde vivem? O que fazem? Anderson Luciano Desenvolvedor Web andersonluciano.me @AndersonLuciano andersonluciano.dev@gmail.com github.com/andersonluciano

×