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.
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.
From a single request to long-running services.
Open source since 1995
We’ve come a long way from a personal home page.
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";
}
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);
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;
}
}
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');
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,
]);
}
}
A package for
almost everything.
A little less reinventing the wheel.
472K
packages published
5.89M
versions
203B+
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.
Extensions, as easy as PIE.
PIE is PHP’s official extension installer. Find, install, and update native extensions with a Composer-like workflow.
Still moving.
Always improving.
More to build with.
Meet PHP 8.5.
- URI Extension
- PHP 8.5 adds a built-in URI extension to parse, normalize, and handle URLs following RFC 3986 and WHATWG URL standards.
- Pipe Operator
- The
|>operator enables chaining callables left-to-right, passing values smoothly through multiple functions without intermediary variables. - Clone With
- Clone objects and update properties with the new
clone()syntax, making the "with-er" pattern simple forreadonlyclasses.
Built by people.
Open by design.
PHP has been community-owned for 30 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.