Book release: PHP for the Web
While Advanced Web Application Architecture is still a work in progress, I decided to release another project in the meantime: a book for beginning PHP developers called PHP for the Web.
Of course, there are PHP books for beginners, but most of them aren't very concise. They cover many related topics like relational databases, CLI applications, and sending emails. I wanted to write a book that only shows what makes PHP so special when it comes to web development.
Writing this book took me back to the beginning of my own programming career in 2002. Many things have changed since then, but surprisingly many things are still the same too!
The biggest change when it comes to dealing with the web in PHP: we now have frameworks. This is obviously a good thing, since it has made our applications much more secure. For instance, in 2002 I wasn't aware of the need for output escaping, or to escape parameters in my SQL queries, and I didn't know that I should protect TinyMCE's upload script against anonymous file uploads...
On the other hand frameworks hide so many of the lower-level details that I dare to say that many PHP developers today don't know how it all works under the hood.
What are cookies and how do they work?
What's the difference between PHP errors and exceptions?
What is $_FILES
and how can I use it?
This new book, PHP for the Web explains it all in over 200 pages.
If you're thinking about learning PHP to build web applications, use the following link to get the book for just $9: https://leanpub.com/learning-php-for-the-web-without-a-framework/c/RELEASE_DAY And if you know someone who thinks about learning PHP, forward this link to them as well!
Here's the table of contents to give you an idea of what's in there. If you want to read a sample, go to the landing page and click on Read Free Sample.
- Serving resources
- Serving an index.html file with the built-in web server
- The project root should not be the document root
- Communication between the browser and the server
- Serving PHP scripts
- The response: status, headers and body
- Linking to other pages
- Passing values between requests
- user input can’t be trusted
- Forms
- Submitting form data as query parameters
- Always use output escaping
- Adding a select element to the form
- Submitting data via the request body
- Cookies
- Setting a cookie
- Using a cookie
- Redirecting after processing a POST request
- Sessions
- Session files and serialized data
- Flash messages
- Using flash messages everywhere
- Authentication
- Setting up a login form
- Logging out
- Project structure
- Header and footer snippets
- Bootstrapping
- Routing
- CRUD part 1: Create
- Saving JSON-encoded data in a file
- Adding a tour
- Form validation
- Listing tours
- CRUD part 2: The rest
- Introducing some reusable elements
- Editing tour data
- Deleting tours
- File uploads
- Uploading a file
- Showing the uploaded picture
- Form validation for file uploads
- Error handling
- Producing an error
- Using different configuration settings in production
- PHP errors
- Automated testing
- Using Composer to install testing tools
- Creating our first browser test
- Starting with a clean slate
- Conclusion
Now go get your copy!