PHP 8 upgrade guide: risks, cost drivers and a step-by-step plan
If your business runs on PHP 7 or an early PHP 8 version, the upgrade is not a technical vanity project. It is risk and cost management. This guide explains why, what makes an upgrade cheap or expensive, and gives a step-by-step plan with tools, config snippets and a safe rollout for a live system.
TL;DR
- Each PHP branch gets about two years of full support and two more of security fixes. Once it ends, known vulnerabilities stay unpatched. That is a business and compliance risk, not just a technical one.
- Cost depends on code size, test coverage, framework age, dependencies and how far you jump, not on PHP itself. Many upgrades are measured in weeks, a neglected one can take months.
- Do it in steps: inventory, CI on the target version, static analysis, automated refactoring with Rector, dependency updates, staging, canary rollout with a rollback.
- Target a version with a long support runway. Check the official supported-versions table before you start, not after.
- Write tests around the money flows (login, checkout, webhooks) first. They are your safety net during the upgrade.
A PHP 8 upgrade is one of those projects that is easy to postpone because nothing visibly breaks. The site still works on PHP 7.4, orders still arrive. Meanwhile the runtime stopped receiving security fixes years ago, libraries have dropped support for it and every new hire asks why the stack is so old. This guide is written for owners and managers who need to decide, budget and sequence the upgrade, with enough technical detail for the team that will do it.
We take over and modernize live PHP systems regularly. This is the plan we follow, and it pairs with the legacy code audit checklist if you want a risk review first.
Why upgrading PHP is a business decision
- Security. PHP versions go through two years of active support and two further years of security-only fixes, then reach end of life. On an unsupported version, newly found vulnerabilities are not fixed in the runtime itself. Attackers read the same public advisories as defenders.
- Compliance and customers. If you take card payments, handle personal data or sell to larger companies, running unsupported software shows up in questionnaires, audits and insurance reviews. Standards such as PCI DSS expect security patches to be applied in a timely way. Ask your auditor or acquirer how this applies to you.
- Ecosystem. Frameworks, SDKs and payment libraries drop old PHP versions. You end up unable to install security updates or new API versions of the services you depend on.
- Hiring and speed. Modern PHP has typed properties, enums, readonly classes, attributes and match expressions. It is faster and easier to maintain, and developers prefer to work on it.
- Cost of waiting. The longer you wait, the larger the version gap, the more breaking changes accumulate and the more expensive the project becomes.
As of this writing, the official table lists 8.2 with security support until the end of 2026, 8.3 until the end of 2027, 8.4 until the end of 2028 and 8.5 until the end of 2029. Always check the supported versions page on php.net when you plan, because dates move forward every year. For a new upgrade, aim at the newest version your dependencies support, so that the next upgrade is not urgent.
What drives the cost
PHP itself is rarely the expensive part. The cost comes from your system:
- Starting version. 7.4 to 8.3 is a larger job than 8.1 to 8.3. Several versions introduced breaking changes and deprecations.
- Framework and library age. An old framework version may need its own upgrade first. This is often the biggest line item.
- Test coverage. With tests, you know what broke. Without them, you test by hand, and every hour of manual testing is a cost.
- Custom and abandoned dependencies. A package that was never updated has to be replaced, patched or removed.
- Code size and style. Large code bases with dynamic tricks (dynamic properties, loose comparisons, error suppression) hide more issues.
- Environment. Shared hosting that cannot run a modern version, manual deployments and missing staging all add work.
Ask your team or vendor for an estimate in ranges and for the assumptions behind it. A trustworthy estimate starts with an inventory and a trial run on a branch, not a number from thin air.
Step-by-step plan
Step 1. Inventory and baseline
Write down what you have: current PHP version, framework and version, installed extensions, composer.json dependencies, cron jobs, integrations, and how deploys work. Check which dependencies already support the target version:
php -v
composer show --direct
composer outdated --direct
composer check-platform-reqs
composer why-not php 8.3
Record a baseline you can compare against: error rate, response time on key pages and the list of flows that must keep working.
Step 2. Put the project in CI on the target version
Run tests and static analysis on the old and new PHP at the same time, so you see breakage as soon as it happens and do not freeze other work. A GitHub Actions matrix is enough:
name: ci
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.3']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- run: composer install --no-interaction --prefer-dist
- run: vendor/bin/phpunit
If you have no tests, write a few smoke tests first: log in, create an order, receive a payment webhook, render the homepage. Ten honest tests on money flows beat a hundred trivial ones.
Step 3. Find problems with static analysis
PHPStan or Psalm finds undefined methods, wrong types and many upgrade traps without running the code. Start at a low level and raise it over time. The compatibility check with PHP_CodeSniffer flags syntax and functions that behave differently in the target version:
composer require --dev phpstan/phpstan squizlabs/php_codesniffer phpcompatibility/php-compatibility
vendor/bin/phpstan analyse src --level=3
vendor/bin/phpcs -p src --standard=PHPCompatibility --runtime-set testVersion 8.3-
Step 4. Automate the boring refactoring with Rector
Rector applies mechanical code changes such as typed properties, constructor promotion and removed function replacements. Review its diff like any other pull request and commit in small steps:
<?php
// rector.php
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([__DIR__ . '/src'])
->withPhpSets(php83: true);
vendor/bin/rector process --dry-run # look first
vendor/bin/rector process # then apply, review, test, commit
Step 5. Fix the usual breaking changes
These are the changes we most often see in real upgrades. The first four matter when moving from 7.x, the rest when moving between 8.x versions:
- Stricter comparisons. In PHP 8,
0 == "abc"is now false. Code that relied on loose comparison between numbers and strings can change behavior silently. Search for==in permission and payment checks first. - Errors instead of warnings. Arithmetic on arrays and calling undefined methods throw exceptions. Old code that hid problems under warnings starts to fail loudly.
- Removed functions and features.
create_function()andeach()are gone. Libraries that use them must be updated or replaced. - Null to internal functions. Passing
nullto a non-nullable parameter of a built-in function is deprecated since 8.1. Expect many log lines in legacy code, which are cheap to fix but numerous. - Dynamic properties. Creating undeclared properties on objects is deprecated since 8.2. Declare the properties, or add the
#[\AllowDynamicProperties]attribute as a temporary bridge. - Implicit nullable parameters. A signature like
function f(Type $x = null)is deprecated since 8.4. Write?Type $x = null.
Make deprecations visible in staging so you can fix them before they become errors in a later version:
; php.ini on staging
error_reporting = E_ALL
display_errors = Off
log_errors = On
error_log = /var/log/php/error.log
Step 6. Update dependencies and the framework
Update libraries to versions that support the target PHP, one group at a time. Set the platform in composer.json so Composer resolves for the version you will run, not the version of your laptop:
{
"require": { "php": "^8.3" },
"config": { "platform": { "php": "8.3.0" } }
}
If the framework itself is old, plan its upgrade as a separate step. Doing both at once makes failures hard to diagnose.
Step 7. Staging, then a gradual rollout
Run the full test suite, then the manual checklist on a staging copy with realistic data. For production, use a gradual approach: run the new PHP version in a second container or pool, send a small share of traffic to it, watch error logs and key business metrics and increase the share. Keep the old version ready:
services:
php83:
image: php:8.3-fpm
volumes: ["./:/var/www/app"]
php74: # keep until the new version is proven
image: php:7.4-fpm
volumes: ["./:/var/www/app"]
Switching back should be a one-line change in the web server configuration, not a redeployment. Pick a low-traffic window, have an owner watching logs and keep the rollback open for at least a week.
After the upgrade
- Remove temporary bridges (dynamic property attributes, old platform settings).
- Keep the CI matrix on the supported versions and update the minimum when the oldest one leaves support.
- Subscribe to release notes of your framework and PHP, and calendar the end-of-life date of your version, so the next upgrade is a planned small project and not an emergency.
- Re-measure speed and error rate against the baseline. Many sites see lower response times, but measure, because results depend on your code. If page speed is a concern, our guide to Core Web Vitals for PHP shows what to fix next.
How we can help
We upgrade live PHP applications in staged steps: inventory, a trial run to produce an honest estimate, CI, Rector and static analysis, then a rollout with rollback. If you are not sure how far behind you are, book a short consultation and share your PHP version and framework, and we will tell you what a realistic path looks like. Learn more about how we take over and stabilize existing systems in our legacy PHP handover article, and see our integrations service for the connected systems that must keep working through the change.
Frequently asked questions
Is it risky to run PHP 7.4 or an older version in production?
Yes. Those versions no longer receive security fixes, so newly discovered vulnerabilities in the runtime remain unpatched. You also lose access to updates in libraries and may fail security questionnaires, audits or insurance reviews. Plan an upgrade rather than waiting for an incident.
How long does a PHP 8 upgrade take?
It depends on the starting version, framework age, test coverage and number of dependencies. A well-maintained app can move in a few weeks, while a neglected system with an old framework and no tests can take months. A trial run on a branch gives the most honest estimate.
Can I jump straight from PHP 7.4 to PHP 8.3 or newer?
Usually yes, but you should handle the breaking changes of each intermediate version. Use static analysis and Rector with a target set, run CI on the old and new versions, and roll out gradually rather than in one switch.
Which PHP version should I upgrade to?
Choose the newest version your framework and dependencies support, because it gives the longest support runway. Check the supported versions page on php.net for current dates before deciding.
Will upgrading PHP make my website faster?
Often it improves speed and memory use, but the result depends on your code, database and caching. Measure response times before and after, and do not expect the upgrade to fix slow queries or heavy pages on its own.
Free discovery call
Bring a messy stack or stalled integration - Integrono will map the smartest first move.
You get a senior take on budget traps, dependencies and whether to buy, glue or build - before paid work starts. The CEO stays in the loop.