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.

Depurando Aplicacoes PHP com XDebug e FirePHP II

5,419 views

Published on

Published in: Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... 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 (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... 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 THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that 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 that 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 That 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 That 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 that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that 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 that 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 That 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 That 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 that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that 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 that 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 That 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 That 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 that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Depurando Aplicacoes PHP com XDebug e FirePHP II

  1. 1. Depurando Aplicações PHP com Xdebug e FirePHP Jefferson Girão http://jefferson.eti.br [email_address]
  2. 2. Murphy, o culpado de tudo. Coronel John Paul Stapp
  3. 3. As Leis <ul><li>Primeira lei - Se uma coisa pode sair errado, sairá. </li></ul><ul><li>Se tudo parece estar indo bem, é porque você não olhou direito. </li></ul><ul><li>A natureza sempre está a favor da falha oculta. </li></ul>&quot;É de conhecimento geral entre os analistas de software que nunca se elimina o último bug de um programa. Os bugs são aceitos como uma triste realidade. Esperamos eliminá-los todos, um por um, mas nunca conseguiremos nos livrar deles.&quot; DeMarco, Tom , Editora Campus, 91
  4. 4. Os Erros <ul><li>Erros nem sempre são óbvios; </li></ul><ul><li>Erros diferentes podem ter a mesma manifestação; </li></ul><ul><li>Saber que um programa não esta correto não necessariamente é saber como corrigir o erro. </li></ul>
  5. 5. Bug? Almirante Grace Hopper
  6. 6. O que fazer? Depurar, testar!! <ul><li>“ Depois eu escrevo o plano de testes...” </li></ul><ul><li>“ Vamos deixar os testes para a próxima fase...” </li></ul><ul><li>“ Na minha máquina funcionou...” </li></ul><ul><li>“ Temos que entregar o produto na semana que vem...” </li></ul>
  7. 7. O que entendemos por depuração? <ul><li>Resolução de problemas (“bugs”): </li></ul><ul><ul><li>Erros Sintáticos / de Interpretação </li></ul></ul><ul><ul><li>Erros Semânticos </li></ul></ul><ul><ul><li>Erros Lógicos </li></ul></ul><ul><ul><li>Avisos e Notificações </li></ul></ul><ul><ul><li>Problemas de Desempenho </li></ul></ul>
  8. 8. Erros Sintáticos Erro sintático acontece quando você se expressa de uma forma não válida para o compilador/interpretador. Quando você não segue a sintaxe da linguagem. Prof. Girafales após cometer um erro sintático: &quot;Eu jamais me engano. Só me enganei uma vez: quando acreditei estar enganado!&quot;
  9. 9. Exemplo de Erro Sintático É um erro fatal!!! Bizu Atenção no destaque de sintaxe da IDE e olhe sempre as linhas anteriores à indicada pela mensagem de erro do PHP.
  10. 10. Cadê os Erros? No php.ini: display_errors = On error_reporting = E_ALL
  11. 11. Erros Semânticos Erros de semântica envolvem códigos técnicamente corretos que contêm problemas com o significado do código. Pica-pau sobre os erros semânticos &quot;Yo no lo conoço señor &quot;
  12. 12. Exemplo de Erro Semântico É um erro fatal!!! Bizu Bizu: verifique se as inclusões foram feitas corretamente e desconfie quando o recurso de autocomplete da IDE não funcionar
  13. 13. Avisos e Notificações Avisos/Notificações podem ser tratados pelo PHP, mas provavelmente não é sobre algo que você não gostaria no seu código Dirty Harry avisando com sua magnum: &quot;Do you feel lucky, punk? &quot;
  14. 14. Exemplo de Aviso/Notificação Bizu Configure o PHP para exibir tudo no php.ini: error_reporting = E_ALL;
  15. 15. Erros Lógicos Simplesmente seu programa não faz o que deveria fazer. Chapolim se deparando com um erro lógico: &quot;Pepe, já tirei a vela. &quot;
  16. 16. Como vamos resolver? <ul><li>Ferramentas </li></ul><ul><ul><li>Mensagens de erro do PHP </li></ul></ul><ul><ul><li>Recursos do Eclipse PDT </li></ul></ul><ul><ul><li>Instruções de impressão </li></ul></ul><ul><ul><li>Xdebug </li></ul></ul><ul><ul><li>Firebug + FirePHP </li></ul></ul>
  17. 17. O que é o XDebug? <ul><ul><li>Não é um sanduíche </li></ul></ul><ul><ul><li>É uma extensão para PHP </li></ul></ul><ul><ul><li>Multiplataforma </li></ul></ul><ul><ul><li>Atualmente na versão 2 </li></ul></ul><ul><ul><li>Criada pelo Derick Rethans (Colaborador chave do PHP) </li></ul></ul><ul><ul><li>Com a finalidade de prover informações para depuração </li></ul></ul><ul><ul><ul><li>e otimização de aplicações </li></ul></ul></ul>www.xdebug.org
  18. 18. Principais recursos do XDebug <ul><ul><li>Melhorias nas mensagens de erro do PHP </li></ul></ul><ul><ul><li>Melhorias na saída do var_dump() </li></ul></ul><ul><ul><li>Proteção contra recursões infinitas </li></ul></ul><ul><ul><li>Depuração remota (Debugging) </li></ul></ul><ul><ul><li>Acompanhamento do fluxo da aplicação (Tracing) </li></ul></ul><ul><ul><li>Informações sobre consumo de recursos (Profilling) </li></ul></ul><ul><ul><li>Cobertura de código (Code Coverage) </li></ul></ul>
  19. 19. Instalação do XDebug <ul><ul><li>Através do código fonte </li></ul></ul><ul><ul><li>Através de binários </li></ul></ul><ul><ul><li>Através do repositório PECL </li></ul></ul>
  20. 20. Instalação do XDebug <ul><ul><li>Configuração do PHP.INI </li></ul></ul><ul><ul><li>No Windows: </li></ul></ul><ul><ul><li>zend_extension_ts=&quot;C:DiretoriodeextensoesdoPHPphp_xdebug.dll&quot; </li></ul></ul><ul><ul><li>No Linux: </li></ul></ul><ul><ul><li>zend_extension=&quot;/diretorio/de/extensoes/do/PHP/xdebug.so&quot; </li></ul></ul><ul><ul><li>Verificando a Instalação através do phpinfo(); </li></ul></ul>
  21. 21. Configurações comuns <ul><li>No php.ini </li></ul><ul><ul><li>xdebug.show_local_vars=On </li></ul></ul><ul><ul><ul><li>Exibe variáveis locais </li></ul></ul></ul><ul><ul><li>xdebug.dump.GET=* </li></ul></ul><ul><ul><ul><li>Mostra o conteúdo da superglobal GET </li></ul></ul></ul><ul><ul><ul><li>(funciona para GET, POST, SERVER, COOKIE, ...) </li></ul></ul></ul><ul><ul><li>xdebug.max_nesting_level=4 </li></ul></ul><ul><ul><li>Define limite de recursão </li></ul></ul>
  22. 22. Debugging <ul><li>No php.ini </li></ul><ul><ul><li>; debug remoto </li></ul></ul><ul><ul><li>xdebug.remote_enable=On </li></ul></ul><ul><ul><li>xdebug.remote_host=&quot;localhost&quot; </li></ul></ul><ul><ul><li>xdebug.remote_port=9000 </li></ul></ul><ul><ul><li>xdebug.remote_handler=&quot;dbgp&quot; </li></ul></ul><ul><li>No Eclipse PDT </li></ul><ul><ul><li>run->open debug dialog...->PHP Web Page->New </li></ul></ul><ul><ul><li>Defina o Server Debugger para Xdebug </li></ul></ul><ul><ul><li>Escolha um arquivo por onde iniciar o debug </li></ul></ul><ul><ul><li>Verifique se a URL autogerada está correta </li></ul></ul><ul><ul><li>Apply->Debug </li></ul></ul>
  23. 23. Tracing V F Comando1 X > 3 Comando4 - Erro Comando2 Comando3
  24. 24. Tracing <ul><li>No php.ini </li></ul><ul><ul><li>xdebug.auto_trace=On </li></ul></ul><ul><ul><li>xdebug.trace_output_dir=D:Temp </li></ul></ul><ul><li>Fazendo tracing de uma parte específica do código </li></ul>
  25. 25. Profilling <ul><ul><li>No php.ini </li></ul></ul><ul><ul><li>xdebug.profiler_output_dir=&quot;D:Temp&quot; </li></ul></ul><ul><ul><li>xdebug.profiler_append=On </li></ul></ul><ul><ul><li>xdebug.profiler_enable_trigger=On </li></ul></ul><ul><ul><li>O KCacheGrind </li></ul></ul>
  26. 26. FirePHP <ul><ul><li>É um plugin para um plugin (dã) do Firefox chamado Firebug </li></ul></ul><ul><ul><li>Permite que Scripts PHP converse com o painel do Firebug </li></ul></ul><ul><ul><li>Todos os dados são enviados via response headers sem </li></ul></ul><ul><ul><li>interferir no conteúdo da página </li></ul></ul><ul><ul><li>Ideal para depuração de aplicações AJAX onde respostas JSON </li></ul></ul><ul><ul><ul><li>e XML simples são necessárias </li></ul></ul></ul>
  27. 27. FirePHP <ul><ul><li>Instalação </li></ul></ul><ul><li>O FireBug </li></ul><ul><li>O FirePHP </li></ul><ul><li>As Bibliotecas </li></ul><ul><ul><li>API Procedural </li></ul></ul><ul><ul><li>API Orientada a Objeto </li></ul></ul>www.firephp.org
  28. 28. Referências <ul><ul><li>Instalação </li></ul></ul><ul><li>http://www.xdebug.org/docs/ </li></ul><ul><li>http://www.firephp.org/HQ/Use.html </li></ul><ul><li>http://devzone.zend.com/article/2803-Introducing-xdebug </li></ul><ul><li>http://www.onlamp.com/public/php/2004/08/12/DebuggingPHP.htm </li></ul><ul><li>http://mikebernat.com/blog/My_PHP_Best_Pratices </li></ul>Obrigado! Dúvidas?

×