PHP 'Deprecated' messages appear in Laravel pages, API responses or logs
Deprecated: ... is deprecated in /vendor/...Short answer
PHP reports E_DEPRECATED at the default error_reporting of E_ALL. Laravel sends deprecations to the channel named in LOG_DEPRECATIONS_CHANNEL, null by default. Keep display_errors Off and APP_DEBUG false in production, route deprecations to their own log file, then fix the code or update the package that triggers them.
Fix it fast
1Find out which cause you have
Check which PHP settings are active for the web server process, not only for the terminal. They decide whether notices are printed into the response.
php -i | grep -E "display_errors|error_reporting|log_errors" grep -n "APP_DEBUG\|LOG_DEPRECATIONS" .env2Match what you see, then jump to its fix
- 1
The notice text appears in the HTML or at the start of a JSON bodydisplay_errors is on, so PHP prints the notice into the responseFix - 2
Laravel shows a detailed error page with deprecation details to visitorsAPP_DEBUG is true in productionFix - 3
You want the notices recorded without flooding laravel.logDeprecations are not routed to a log channel you can readFix - 4
Notices come from a PHP version upgrade; PHP 8.0 and later default to E_ALLE_DEPRECATED is part of error_reportingFix
- 1
What does the error look like?
Deprecated: ... is deprecated in /vendor/...A JSON API response starts with PHP warning text
Cause 1 of 4
display_errors is on, so PHP prints the notice into the response
1Check
display_errors defaults to On, php.ini-development sets it On, and php.ini-production sets it Off. The manual says it should never be used on production systems.
php --ini && php -r 'echo ini_get("display_errors");'2Fix
Turn it off in php.ini for production and keep errors in a log instead, as the manual advises.
display_errors = Off
log_errors = On3Verify
Reload PHP-FPM or Apache and repeat the request. The response is clean.
sudo systemctl reload php8.3-fpmConfirmed by php.net
Cause 2 of 4
APP_DEBUG is true in production
1Check
The debug option follows APP_DEBUG in .env. Laravel says it should always be false in production, because true can expose sensitive configuration values.
grep -n APP_DEBUG .env2Fix
Set APP_DEBUG=false and rebuild the cached config.
APP_DEBUG=false
php artisan config:cache3Verify
Reload the page. Visitors see the normal error page, not details.
grep -n APP_DEBUG .envConfirmed by laravel.com
Cause 3 of 4
Deprecations are not routed to a log channel you can read
1Check
Laravel logs deprecations to the channel named by LOG_DEPRECATIONS_CHANNEL, or to a channel called deprecations if one exists. The default is null.
grep -n -A4 "deprecations" config/logging.php2Fix
Define a deprecations channel that writes to its own file, so you can review them without noise in the main log.
// config/logging.php
'channels' => [
'deprecations' => [
'driver' => 'single',
'path' => storage_path('logs/php-deprecation-warnings.log'),
],
],3Verify
Trigger the code path and read the new file.
tail -n 20 storage/logs/php-deprecation-warnings.logConfirmed by laravel.com
Cause 4 of 4
E_DEPRECATED is part of error_reporting
1Check
Before PHP 8.0 the default excluded E_DEPRECATED; since 8.0 the default is E_ALL, so deprecations are reported.
php -r 'echo error_reporting(), PHP_EOL;'2Fix
On production you may exclude E_DEPRECATED from what is displayed, but still log them and fix the source: update the package or change the call that is deprecated.
; php.ini, production
error_reporting = E_ALL & ~E_DEPRECATED3Verify
Restart PHP and check the effective value.
php -r 'echo error_reporting(), PHP_EOL;'Confirmed by php.net
How do I stop it coming back?
- Keep display_errors Off and APP_DEBUG false in production.
- Review the deprecations log after every PHP or package upgrade, not only on release day.
- Update the package named in the notice; hiding it only postpones the break.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix