Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

PHP 'Deprecated' messages appear in Laravel pages, API responses or logs

ErrorDeprecated: ... 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.

  • Applies to PHP 8.3, PHP 8.4, Laravel 11, Laravel 12
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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" .env
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2Laravel shows a detailed error page with deprecation details to visitorsAPP_DEBUG is true in productionFix
    3. 3You want the notices recorded without flooding laravel.logDeprecations are not routed to a log channel you can readFix
    4. 4Notices come from a PHP version upgrade; PHP 8.0 and later default to E_ALLE_DEPRECATED is part of error_reportingFix

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 = On

3Verify

Reload PHP-FPM or Apache and repeat the request. The response is clean.

sudo systemctl reload php8.3-fpm

Confirmed by php.net

Did this fix it?

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 .env

2Fix

Set APP_DEBUG=false and rebuild the cached config.

APP_DEBUG=false

php artisan config:cache

3Verify

Reload the page. Visitors see the normal error page, not details.

grep -n APP_DEBUG .env

Confirmed by laravel.com

Did this fix it?

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.php

2Fix

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.log

Confirmed by laravel.com

Did this fix it?

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_DEPRECATED

3Verify

Restart PHP and check the effective value.

php -r 'echo error_reporting(), PHP_EOL;'

Confirmed by php.net

Did this fix it?

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 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 fix

Back 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.