PHP 102: Out with the Bad, In with the Good

Embed Size (px)

DESCRIPTION

We'll look at a typical first PHP application, review a few of the horrible mistakes the fictional developer made, and then refactor the app according to some best practices. Along the way you might even learn a thing or two about PHP you don't already know.Presented at Memphis PHP on Feb 23, 2012.

Citation preview

  • 1. PHP 102 Out with the Bad, In with the Good Memphis PHP, February 23, 2012

2. Who is this guy?

  • Jeremy Kendall PHP developer since about 2001 Organizer of Memphis PHP Zend Frameworkexpertfanboi Speaker Photographer Sometime blogger Sometime open source contributor

3. Following Along

  • You can follow along with the presentation code at github.com. http://git.io/eAUNow

4. Why Did YouStart Programming? 5. I wanted to solve problems, but . . . 6. . . . I frequently causedas many problemsas I solved. 7. Let's Solve a Problem Together

  • We'll create a typical first web application

8. Make horrible mistakes 9. Correct those mistakes 10. Make a cool improvement 11. Learn something? 12. What's the Problem?

  • I want to create an application that stores and displays books from my bookshelf

13. Requirements:

  • Display books

14. Add books 15. Edit books 16. Delete books Why no delete? I ran out of time and energy. 17. So, What do we Need?

  • Database (sqlite)

18. View (index.php) 19. Form (book-form.php) 20. Form processor (process-form.php) 21. index.php db connection < table > < tr > < th > Title th >< th > Author th > tr > < tr > < td > < a href= "book-form.php?id=" > a > td > < td > td > tr > table > < p > We have no books! p > 27. index.php books table < table > < tr > < th > Title th >< th > Author th > tr > < tr > < td > < a href= "book-form.php?id=" > a > td > < td > td > tr > table > < p >We have no books! p > 28. index.php books table < table > < tr > < th >Title th >< th >Author th > tr > < tr > < td > < a href= "book-form.php?id=" > a > td > < td > td > tr > table > < p >We have no books! p > 29. index.php books table < table > < tr > < th >Title th >< th >Author th > tr > < tr > < td > < ahref="book-form.php?id="> a > td > < td > td > tr > table > < p > We have no books! p > 30. 31. book-form.php 32. book-form.php