PHP — Not Just a "Language for Business Card Websites"
\n\nFor a long time, there was a stereotype in the developer community: PHP is a language for simple blogs, online stores, and "quick-and-dirty websites." Reality, as usual, is more complex and interesting. Today, PHP powers the core of giants such as Facebook (now Meta), Wikipedia (the largest encyclopedic resource on the planet), Mail.ru, and Etsy. Moreover, 77% of all websites whose programming language is known use PHP (W3Techs data for 2024).
\n\nIn this article, we will analyze real cases of companies that not only use PHP but also scale it to millions of requests per second. You will see what production code looks like, what architectural decisions were made, and what lessons can be learned for your own projects.
\n\nCase #1: Facebook and HHVM — When PHP "Outgrew" Itself
\n\nThe Problem: Traditional PHP Couldn't Handle the Load
\n\nIn 2010, Facebook faced a classic growth problem: the number of users exceeded 500 million, and the number of PHP requests per page numbered in the hundreds. The standard PHP interpreter (Zend Engine) consumed too much memory and CPU. Each request was processed from scratch — compilation, execution, context destruction.
\n\nFacebook engineers took an unconventional path: they created HipHop for PHP, and then HHVM (HipHop Virtual Machine). This is not just optimization, but a full-fledged JIT compilation of PHP into machine code.
\n\nArchitectural Solution: JIT Compilation and the Hack Language
\n\nHere is what a typical piece of code processed by HHVM looks like:
\n\n<?php\n\n// Example from Facebook's real code (adapted)\nclass FeedManager {\n private Redis $cache;\n private Database $db;\n \n public function getUserFeed(int $userId, int $limit = 20): array {\n // Try to get from cache\n $cacheKey = "feed:user:{$userId}";\n $cached = $this->cache->get($cacheKey);\n \n if ($cached !== null) {\n return json_decode($cached, true);\n }\n \n // Generate feed with pagination\n $feed = $this->db->query(\n "SELECT * FROM posts WHERE author_id IN (\n SELECT friend_id FROM friendships WHERE user_id = ?\n ) ORDER BY created_at DESC LIMIT ?",\n [$userId, $limit]\n )->fetchAll();\n \n // Cache for 5 minutes\n $this->cache->set($cacheKey, json_encode($feed), 300);\n \n return $feed;\n }\n}\n\n\nKey features:
\n- \n
- Typing — HHVM supports strict typing (int, string, array), which reduces the number of bugs by 40%. \n
- Asynchrony — HHVM can work with async/await, which is critical for processing thousands of parallel requests. \n
- Profiling — each request is logged and analyzed for bottlenecks. \n
Result
\nPerformance increased by 5-6 times compared to standard PHP. Server energy consumption decreased by 50%. Meta now uses HHVM to process billions of requests daily.
\n\nCase #2: Wikipedia — PHP Without Frameworks, But With Smart Architecture
\n\nThe Problem: How to Support 300+ Languages and 50 Million Articles?
\n\nWikipedia (the MediaWiki engine) is one of the oldest PHP projects. The codebase contains over 2 million lines of PHP. Interestingly, they deliberately abandoned popular frameworks (Laravel, Symfony) in favor of their own solution.
\n\nArchitectural Solution: Modularity and Caching
\n\nHere is what a typical page handler in MediaWiki looks like:
\n\n<?php\n\n// Simplified example from MediaWiki core\nclass ArticlePageHandler {\n \n public function render(string $title): string {\n