The web runs
on PHP.
Build websites, APIs, and applications with a modern, open source language, mature tools, and a global community. It's a scripting language too, just as strong on the command line as on the web.
Powered by PHP
Everything the web needs.
Security. AI & agents. APIs & JSON. Databases. Scalability. Performance. PHP connects the pieces of the modern web.
Made for the web.
From the beginning.
PHP has grown with the web. From dynamic pages and forms to data pipelines and AI agents, the language and its ecosystem grow with your application.
We’ve come a long way from a personal home page.
Attributes, typed properties, and constructor injection; a whole JSON endpoint in one class.
<?php
// Map a web request to a JSON response.
class UserController
{
public function __construct(
private readonly UserRepository $users,
) {}
#[Route('/users/{id}', methods: ['GET'])]
public function show(int $id): Response
{
$user = $this->users->find($id)
?? throw new NotFoundException();
return Response::json([
'id' => $user->id,
'name' => $user->name,
]);
}
}
Terminal
Example session
curl localhost:8000/users/42 {"id":42,"name":"Ada Lovelace"}
Attributes describe arguments and options; the method signature is the command.
<?php
// Turn a plain method into a command-line tool.
#[AsCommand('greet', 'Say hello to someone')]
class GreetCommand
{
public function __invoke(
OutputInterface $output,
#[Argument] string $name,
#[Option] bool $shout = false,
): int {
$greeting = "Hello, {$name}!";
$output->writeln($shout ? strtoupper($greeting) : $greeting);
return Command::SUCCESS;
}
}
Terminal
Example session
php bin/console greet Ada --shout HELLO, ADA!
Code against PSR standard interfaces, then plug in whichever HTTP client you like.
<?php
// Call a JSON API with an HTTP client.
function releaseDate(
ClientInterface $http,
RequestFactoryInterface $requests,
string $version,
): string {
$request = $requests
->createRequest('GET', "https://www.php.net/releases/?json&version={$version}")
->withHeader('Accept', 'application/json');
$response = $http->sendRequest($request);
$release = json_decode($response->getBody(), flags: JSON_THROW_ON_ERROR);
return $release->date;
}
echo releaseDate(new GuzzleHttp\Client(), new GuzzleHttp\Psr7\HttpFactory(), '8.0.0');
Terminal
Example session
php release_date.php 26 Nov 2020
Generators walk a file larger than memory, one record at a time.
<?php
// Read a compressed event log, one record at a time.
function events(string $file): Generator
{
$stream = new SplFileObject("compress.zlib://$file");
foreach ($stream as $line) {
if (trim($line) !== '') {
yield json_decode($line, flags: JSON_THROW_ON_ERROR);
}
}
}
foreach (events('events.ndjson.gz') as $event) {
echo "{$event->type}\n";
}
Terminal
Example session
php stream_large_dataset.php invoice.created payment.received order.shipped
Fetch a live page and query it with CSS selectors, using the built-in DOM parser.
<?php
// Fetch a live page and extract its headlines with CSS selectors.
$html = file_get_contents('https://www.php.net/archive/2026.php');
$page = Dom\HTMLDocument::createFromString($html, LIBXML_NOERROR);
$headlines = [];
foreach ($page->querySelectorAll('article h2') as $heading) {
$headlines[] = trim($heading->textContent);
}
// The archive is newest-first, so the year's first posts are at the end.
echo json_encode(array_slice(array_reverse($headlines), 0, 3), JSON_PRETTY_PRINT);
Terminal
Example session
php extract_headlines.php [ "PHP Velho Oeste 2026", "PHP 8.4.17 Released!", "PHP 8.3.30 Released!" ]
A package for
almost everything.
A little less reinventing the wheel.
480 thousand
packages published
6.06 million
versions
more than 213 billion
installs
Composer + Packagist
Declare what your project needs, lock exact versions, and install the same dependency graph everywhere. Search Packagist to find packages for databases, APIs, testing, queues, files, and almost everything between.
Still moving.
Always improving.
More to build with.
8.6
Released November 19, 2026
Meet PHP 8.6.
- Partial Function Application
- Fill in some of a function’s arguments now with
?and...placeholders, and get back a Closure that takes the rest. - Duration Class
- The new
Time\Durationclass expresses timeouts and benchmark timings with nanosecond precision, independent of any clock or timezone. - Polling API
Io\Pollwatches many streams at once using epoll, kqueue, and other native mechanisms, without the limits ofstream_select().
Built by people.
Open by design.
PHP has been community-owned for 31 years. The language evolves through public proposals, discussion, and votes, and is free from corporate control.
Contribute to the language, improve the docs, or help someone find their feet. There’s a place for you here.
Funding the people behind PHP.
Your support funds work on PHP’s core, helping maintain and improve the language that so much of the web depends on.
Get started.
Get PHP running, find your feet in the language, and explore a world of packages ready to help.
-
Get set up.
Install PHP locally or configure it for your servers. Find the setup that fits your tools and infrastructure.
-
Learn the language.
Dive into the documentation or follow a guided tutorial. Explore the features, functions, and patterns you’ll use.
-
Explore the package ecosystem.
Find reusable packages and native extensions for the work your application needs to do.
PHP through the years.
Three decades of releases. Drag, scroll, or use your arrow keys to explore. Open any version for its notes, or read the story.
Drag or scroll horizontally to explore releases. Follow a version to read its release details. Use the arrow keys to move between releases, or Home and End to jump to the first and last. Taller marks indicate major versions. PHP 6 was never released.