Laravel app stopped working after upgrading to php 8

Laravel app stopped working after upgrading to php 8

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Laravel app stopped working after upgrading to php 8

When you upgrade your PHP version on macOS, it often feels like a simple housekeeping task until the application suddenly fails to boot. The error logs immediately scream ReflectionParameter::getClass() is deprecated. This specific deprecation notice appears repeatedly in the Laravel framework source code, specifically within /vendor/laravel/framework/src/Illuminate/Container/Container.php.

At first glance, the stack trace points directly into the core Container class, which can be misleading. It suggests that your custom application logic or a specific service provider is invoking deprecated methods. However, in this scenario, the root cause lies entirely within the Laravel framework's internal implementation of its dependency injection container. The framework itself is attempting to inspect type hints on function arguments using the ReflectionParameter::getClass() method.

In PHP 8, this behavior was flagged as deprecated because the underlying reflection API changed how it handles class names for typed parameters. The method no longer returns a string directly but instead requires accessing the getClassName() property or method to retrieve the name of the class. While the deprecation warnings are noisy and annoying in the CLI output, they do not immediately stop your application from running if the framework is up to date. However, if you see these errors persisting after an upgrade without any actual code changes on your end, the issue is almost certainly a version mismatch between your Laravel installation and your PHP runtime.

The primary solution involves ensuring that your Laravel version supports the PHP 8 runtime. If you are running an older version of Laravel, such as 9.x, it may contain internal calls to ReflectionParameter::getClass() that were not updated to handle the new PHP 8 reflection API correctly. The framework officially dropped support for PHP 7 in later versions and shifted its internal implementations to align with PHP 8's stricter typing and reflection rules.

To resolve this, you should check your current Laravel version:

php artisan --version

If you are on version 9 or earlier, the recommended path is to upgrade to Laravel 10 or later. These versions have migrated their internal container logic to use ReflectionParameter::getDeclaringClass()->getName() or similar non-deprecated alternatives, effectively silencing these specific warnings.

Before attempting a major upgrade, verify that your composer.json does not lock you into an older PHP constraint. Sometimes, the package manager defaults to installing compatible dependencies based on the declared PHP version. Run the following command to ensure Composer is aware of your new PHP installation:

composer require --dev illuminate/support:^10.0

If a direct upgrade feels too risky for production, you can attempt to suppress these specific deprecation warnings temporarily using php.ini settings or by adjusting how your server handles deprecated function errors, though this is not a long-term fix. The goal remains updating the framework internals to match the PHP 8 reflection API standards.

Once the framework version aligns with the PHP runtime, the deprecation notices regarding ReflectionParameter::getClass() should vanish. If you continue to see these errors after upgrading Laravel, investigate your custom service providers or traits that might explicitly call the deprecated method, though this is rare in standard boilerplate code. The overwhelming likelihood is that an outdated framework core is trying to run on a newer PHP engine without the necessary internal patches.

Our network