PHP for the Web
$10.00
Minimum price
$15.00
Suggested price

PHP for the Web

Learn PHP without a framework

About the Book

This book is for people who want to learn to build web applications with PHP. It doesn't focus on PHP programming, but shows how PHP can be used to serve dynamic web pages. You'll discover all the basic ingredients of a web application.

We won't use a framework like Symfony or Laravel, we'll only work with plain PHP. This allows us to focus on the core ideas, instead of how a particular framework implements them.

After reading this book you'll know how to use multiple web technologies like POST requests, forms, sessions, and redirects to build a CRUD application with an authentication system.

About the Author

Matthias Noback
Matthias Noback

Matthias Noback has been building web applications since 2003. He is the author of A Year With Symfony, Principles of Package Design and Object Design Style Guide. He is a regular blogger, public speaker and trainer.

Packages

The Book
  • English

  • PDF

  • EPUB

  • MOBI

  • WEB

$10.00
Minimum price
$15.00
Suggested price
Six-pack

Get 6 copies to give away to friends and co-workers

  • English

  • PDF

  • EPUB

  • MOBI

  • WEB

$25.00
Minimum price
$50.00
Suggested price

Table of Contents

  • Introduction
    • Who should read this book?
    • Getting started
      • Bash
      • PHP Runtime
      • An IDE that works well with PHP
      • Firefox
    • An overview of the contents
    • The source code
    • Acknowledgements
    • Feedback and suggestions
  • 1. Serving resources
    • Serving an index.html file with the built-in web server
    • Adding a favicon
    • Security announcement: The project root should not be the document root
    • Communication between the browser and the server
    • Summary
  • 2. Serving PHP scripts
    • The response: status, headers and body
    • Building up a response
    • Linking to other pages
    • Passing values between requests
    • Security announcement: user input can’t be trusted
    • Summary
  • 3. Forms
    • Submitting form data as query parameters
    • Security announcement: Always use output escaping
    • Adding a select element to the form
    • Submitting data via the request body
    • Summary
  • 4. Cookies
    • Setting a cookie
    • Using a cookie
    • Set-Cookie is a response header, Cookie a request header
    • Redirecting after processing a POST request
    • Security announcement: cookies can be manipulated without you knowing
    • Summary
  • 5. Sessions
    • Session files and serialized data
    • Flash messages
    • Using flash messages everywhere
    • Summary
  • 6. Authentication
    • Setting up a login form
    • Logging out
    • Summary
  • 7. Project structure
    • Header and footer snippets
    • Passing variables to snippets
    • Flash messages revisited
    • Bootstrapping
    • From .html to .php
    • Adding navigation
    • Adding a stylesheet
    • Routing
    • Summary
  • 8. CRUD part 1: Create
    • Saving JSON-encoded data in a file
    • Adding a tour
    • Form validation
    • Showing the submitted data in the form
    • Listing tours
    • Summary
  • 9. CRUD part 2: The rest
    • Introducing some reusable elements
    • Editing tour data
    • Deleting tours
    • Summary
  • 10. File uploads
    • Adding a details page
    • Uploading a file
    • Processing the file upload
    • Showing the uploaded picture
    • Replacing the existing image
    • Form validation for file uploads
    • Summary
  • 11. Error handling
    • Producing an error
    • Using different configuration settings in production
    • PHP errors
    • Summary
  • 12. Automated testing
    • Using Composer to install testing tools
    • A first test
    • Creating our first browser test
    • A test for the pictures page
    • Starting with a clean slate
    • Troubleshooting and suggestions
    • Summary
  • 13. Conclusion
    • Object-oriented programming
    • Frameworks
    • Testing
    • Parting words
  • Appendix A: Installing PHP on Windows

Authors have earned$9,651,785writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub