PHP for the Web
$20.00
Minimum price
$25.00
Suggested price

PHP for the Web

Learn PHP without a framework

About the Book

"PHP for the Web is a terrific introduction on how to use modern PHP effectively. The book is well suited for anyone with a basic knowledge of PHP or someone coming from another programming language. I was able to easily follow along, and I developed a good sense of the strengths of PHP for web development. I am currently learning more about object-oriented PHP, and frameworks like Symfony, and I felt that this book gave me a solid foundation." -- Jason Pollard

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.

Each chapter comes with a set of Quiz questions so you can test your knowledge. On top of the practical exercises in the book there are 5 additional Challenges that help you practice the techniques from this book on your own. The solutions are available on GitHub.

"An excellent book to learn or refresh the base of PHP" -- @lambeletjp

Educative.io has created an interactive course based on this book. You can write PHP in your browser and they can even run the code for you. Register here: https://www.educative.io/courses/php-web-learn-php-without-framework/

Translations

About the Author

Matthias Noback
Matthias Noback

Matthias Noback has been building web applications since 2003. He is the author of Principles of Package Design and Object Design Style Guide and Advanced Web Application Architecture. He is a regular blogger, public speaker and trainer.

Packages

The Book
  • PDF

  • EPUB

  • WEB

  • English

$20.00
Minimum price
$25.00
Suggested price
Six-pack

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

  • PDF

  • EPUB

  • WEB

  • English

$60.00
Minimum price
$75.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
    • Changelog
      • 31 January 2021
    • Shortened several lines in code samples that were too long to show on the page and were cut in two by a backslash, which produces incorrect code.
  • 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
    • Quiz
  • 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
    • Quiz
  • 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
    • Quiz
  • 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
    • Quiz
    • Challenge
  • 5. Sessions
    • Session files and serialized data
    • Flash messages
    • Using flash messages everywhere
    • Summary
    • Quiz
  • 6. Authentication
    • A secret page
    • Setting up a login form
    • Validating the username and the password
    • Logging out
    • Summary
    • Quiz
  • 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
    • Quiz
    • Challenge
  • 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
    • Quiz
    • Challenge
  • 9. CRUD part 2: The rest
    • Introducing some reusable elements
    • Editing tour data
    • Deleting tours
    • Summary
    • Quiz
    • Challenge
  • 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
    • Quiz
  • 11. Error handling
    • Producing an error
    • Using different configuration settings in production
    • PHP errors
    • Summary
    • Quiz
  • 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
    • Quiz
    • Challenge
  • 13. Conclusion
    • Object-oriented programming
    • Frameworks
    • Testing
    • Parting words
  • Appendix A: Installing PHP on Windows
  • Appendix B: Answers to the quiz questions
    • Chapter 1
    • Chapter 2
    • Chapter 3
    • Chapter 4
    • Chapter 5
    • Chapter 6
    • Chapter 7
    • Chapter 8
    • Chapter 9
    • Chapter 10
    • Chapter 11
    • Chapter 12

The Leanpub 60 Day 100% Happiness Guarantee

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

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

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) and EPUB (for phones, tablets and 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. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub