# The PHP Guide

> Learn PHP from scratch: setup, first programs, handling HTTP requests, forms, cookies, sessions, errors, Composer, and deploying PHP applications.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2026-07-14 | Topics: [PHP](https://flaviocopes.com/tags/php/) | Canonical: https://flaviocopes.com/php/

PHP powers a huge portion of the web. WordPress, Laravel, and countless custom applications run on it.

It gets dismissed a lot, but PHP is a pragmatic, productive language. It was built for the web from day one. You write a file, put it on a server, and it works. That directness is still one of its biggest strengths.

The fundamentals here don't age: how requests work, how forms are processed, how sessions keep users logged in. These are the mechanics of the web itself, expressed in PHP.

This page is your map to the PHP content on this site.

## Where to start

Two posts get you from nothing to running code:

- [How to set up PHP](https://flaviocopes.com/php-setup/) covers installing PHP on your machine
- [How to create your first PHP program](https://flaviocopes.com/php-first-program/) gets you writing and running code

## PHP and the web

This is where PHP shines. These posts cover the request-response cycle and everything around it:

- [Handling HTTP requests in PHP](https://flaviocopes.com/php-http-requests/) explains how PHP receives and answers requests
- [How to use forms in PHP](https://flaviocopes.com/php-forms/) covers accepting user input
- [How to use HTTP Headers in PHP](https://flaviocopes.com/php-http-headers/)
- [How to use Cookies in PHP](https://flaviocopes.com/php-cookies/) to store data in the browser
- [How to use PHP Cookie-based Sessions](https://flaviocopes.com/php-sessions/) to keep state across requests, like logins

My advice: read these in order. Forms build on requests, sessions build on cookies.

## Errors and files

Things go wrong, and programs need to touch the filesystem:

- [How to deal with errors in PHP](https://flaviocopes.com/php-errors/)
- [How to use exceptions in PHP](https://flaviocopes.com/php-exceptions/)
- [How to work with files/folders in PHP](https://flaviocopes.com/php-files-folders/)

## The ecosystem

Modern PHP is built on packages and needs a home in production:

- [How to use Composer and Packagist in PHP](https://flaviocopes.com/php-composer-packagist/) covers the package manager every PHP project uses
- [Deploying PHP applications](https://flaviocopes.com/php-deployment/) covers getting your code on a server

Once you're comfortable with plain PHP, the natural next step is a framework. I wrote a full learning path for that in [the Laravel guide](https://flaviocopes.com/laravel/).

## Go deeper

I collected all of this material in the free [PHP Handbook](https://flaviocopes.com/ebooks/php-handbook/). It's a structured walk through the language and its web features, downloadable as PDF or EPUB.

All posts on this topic are in the [PHP tag archive](https://flaviocopes.com/tags/php/).
