How to disable deprecated messages in Laravel

How to Stop Laravel Deprecated Messages (Quick Fix 2026)

Table of Contents

Deprecated messages slowing your Laravel app? Learn 3 proven methods to disable deprecated warnings in Laravel. Includes config/app.php setup, testing steps, and performance optimization tips. Works with Laravel 7, 8, 9, 10, and 11.

Quick Answer: Does APP_DEBUG=false Suppress Deprecation Warnings?

No, setting APP_DEBUG=false does NOT suppress deprecation warnings in Laravel.

This is one of the most common misconceptions among Laravel developers. The APP_DEBUG setting in your .env file only controls whether error details are displayed in the browser during development. It does not affect deprecation warnings that appear in your logs or console.

Here’s what APP_DEBUG actually controls:

  • When APP_DEBUG=true: Detailed error pages are shown in the browser
  • When APP_DEBUG=false: Generic error pages are shown to users (production mode)

Deprecation warnings will still appear in your Laravel logs (storage/logs/laravel.log) and console output regardless of the APP_DEBUG setting. To actually suppress deprecation warnings, you need to use the methods described below.

Methods Comparison: Which One Should You Use?

MethodSuppresses WarningsProduction SafeRecommended
APP_DEBUG=falseNoYesNot for this purpose
error_reporting configYesYesYes – Best method
php artisan optimizePartial (cache only)YesUse with other methods
Laravel Error HandlerYesYesAdvanced users

What are Deprecated Messages in Laravel?

In the world of web development, Laravel has become one of the most popular PHP frameworks due to its simplicity, elegance, and powerful features. However, like any software project, Laravel is not without its issues. One common problem that developers may encounter when working with Laravel is deprecated messages.

Deprecated messages are warnings that indicate a function, method, or feature that is no longer recommended and may be removed in future versions of the software. In Laravel, these warnings help developers identify code that needs updating to maintain compatibility with newer framework versions.

Here are some examples of deprecated messages that you may encounter in your Laravel projects:

  • Functions or methods that have been replaced with newer, more efficient alternatives
  • Configuration options that are no longer supported in the latest versions of Laravel
  • Syntax or coding practices that may lead to performance issues or vulnerabilities

Deprecated messages can have a significant impact on the performance and stability of your application. Ignoring deprecated messages can lead to code that is difficult to maintain, slower performance, and potential security vulnerabilities.

Why Disable Deprecated Messages in Laravel?

There are several important reasons why developers should take the time to disable deprecated messages in their Laravel projects:

1. Avoiding confusion during development

Deprecated messages can clutter your development environment with unnecessary warnings, making it difficult to identify legitimate issues in your code. Disabling deprecated messages can help streamline the development process and improve code readability.

2. Optimizing application performance

Deprecated messages can slow down the performance of your application by introducing unnecessary overhead. By disabling deprecated messages, you can ensure that your application runs smoothly and efficiently.

3. Ensuring code quality and compliance

Ignoring deprecated messages can lead to code that is not compliant with Laravel best practices, making it difficult to maintain and update in the future. By disabling deprecated messages, you can ensure that your code is clean, efficient, and up to date with the latest Laravel standards.

4 Methods to Disable Laravel Deprecation Warnings

Method 1: Modify error_reporting in config/app.php (Recommended)

This is the most straightforward and recommended method for disabling deprecation warnings in Laravel. It works across all Laravel versions (7, 8, 9, 10, and 11).

Step 1: Update Laravel version to the latest stable release

Before disabling deprecated messages, ensure you are running the latest stable version of Laravel. This will help prevent future deprecated messages and ensure that your application is up to date with the latest features and improvements.

Step 2: Modify config/app.php file

To disable deprecated messages in Laravel, modify the config/app.php file in your project. Open the file in a text editor and locate or add the error_reporting configuration.

Add this line to your config/app.php file:

'error_reporting' => E_ALL & ~E_DEPRECATED & ~E_STRICT,

This configuration tells PHP to report all errors except deprecated warnings and strict standards notices.

Step 3: Testing the changes

After modifying the config/app.php file, test your application to ensure that deprecated messages are no longer being displayed. Run your tests and check for any remaining deprecated messages to confirm that the changes have been successful.

Method 2: Using php artisan optimize Command

The php artisan optimize command is useful for clearing and caching configuration, routes, and views. While it doesn’t directly suppress deprecation warnings, it can help reduce console clutter during development.

Run these commands in sequence:

php artisan config:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache

What each command does:

  • config:clear – Removes cached configuration files
  • config:cache – Creates a single cached file for faster config loading
  • route:cache – Caches all route registrations
  • view:cache – Compiles all Blade templates

Note: Use this method in combination with Method 1 for best results. This alone won’t suppress all deprecation warnings.

Method 3: Custom Error Handler Configuration

For more advanced control, you can create a custom error handler in your Laravel application. This method is recommended for developers who need fine-grained control over error reporting.

Edit your app/Exceptions/Handler.php file and add:

public function register()
{
    error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);

    $this->reportable(function (Throwable $e) {
        // Custom error handling logic
    });
}

This gives you more control over which errors to suppress and allows you to add custom logging or handling for specific error types.

Method 4: Environment-Specific Configuration

You can also configure deprecation warnings differently for development and production environments by using .env files.

In your config/app.php, add:

'error_reporting' => env('ERROR_REPORTING', E_ALL & ~E_DEPRECATED & ~E_STRICT),

Then in your .env file:

# For development - show all errors including deprecated
ERROR_REPORTING=E_ALL

# For production - hide deprecated warnings
ERROR_REPORTING=32759  # This equals E_ALL & ~E_DEPRECATED & ~E_STRICT

Laravel 7 Specific Deprecation Issues

Laravel 7 users may encounter specific deprecation warnings when upgrading to Laravel 8 or running on newer PHP versions. Here are the most common issues and their solutions:

Issue: logger.php implicitly marking parameter $dispatcher as nullable

This warning appears when using php artisan serve with Laravel 7 on PHP 8.0+.

Solution: Either upgrade to Laravel 8+ or modify vendor/laravel/framework/src/Illuminate/Log/LogManager.php (not recommended for production). Better approach: Use the error_reporting method above to suppress these warnings.

Issue: illuminate\log\logger::__construct() deprecation

PHP 8 compatibility issue with Laravel 7’s logging system.

Solution: Update to Laravel 8 or apply the error_reporting configuration from Method 1 above. This is a framework-level issue that cannot be fixed without upgrading.

Issue: object_get deprecated

The object_get() helper function was deprecated in Laravel 7 and removed in Laravel 9.

Solution: Replace object_get() calls with data_get() or direct property access. Example:

// Old (deprecated)
$value = object_get($object, 'property.nested');

// New (recommended)
$value = data_get($object, 'property.nested');
// or
$value = $object->property->nested ?? null;

Frequently Asked Questions (FAQs)

1. Does app_debug=false suppress deprecation warnings in Laravel?

No, APP_DEBUG=false only controls error display in the browser, not deprecation warnings in logs. Deprecation warnings will still appear in storage/logs/laravel.log regardless of the APP_DEBUG setting. To suppress deprecation warnings, use the error_reporting configuration method described above.

2. Can deprecated messages be safely ignored in Laravel projects?

It is not recommended to ignore deprecated messages in Laravel projects, as they can indicate potential issues in your code that may lead to performance issues or security vulnerabilities. It is important to address deprecated messages promptly to ensure that your code remains clean, efficient, and up to date with the latest Laravel standards.

3. Are there any tools available to help identify deprecated messages in Laravel applications?

Yes, there are several tools available to help identify deprecated messages in Laravel applications. Popular tools like Laravel Shift and Laravel IDE Helper can analyze your codebase and highlight deprecated functions, methods, or features that need to be updated or replaced. These tools can help streamline the process of addressing deprecated messages in your Laravel projects.

4. What are the potential risks of not disabling deprecated messages in Laravel projects?

Leaving deprecated messages unaddressed in Laravel projects can lead to code that is difficult to maintain, slower performance, and potential security vulnerabilities. Ignoring deprecated messages can also make it harder to update your code to the latest version of Laravel and stay compliant with the latest standards and best practices.

5. Is it necessary to disable deprecated messages in all Laravel projects?

While it is important to disable deprecated messages in most Laravel projects, the necessity may vary depending on the specific requirements and constraints of your project. It is important to consider factors such as project scope, timeline, and resources when deciding whether to disable deprecated messages in your Laravel projects. However, in general, it is recommended to address deprecated messages promptly to ensure code quality and compliance with Laravel best practices.

6. Will php artisan optimize suppress deprecation warnings?

The php artisan optimize command primarily caches configuration and routes. It does not directly suppress deprecation warnings. However, it can reduce console output clutter by caching files. For complete suppression of deprecation warnings, use it in combination with the error_reporting configuration method.

7. How do I suppress deprecation warnings in Laravel Artisan commands?

Use the error_reporting configuration in config/app.php (Method 1). This will apply to all parts of your Laravel application, including Artisan commands. If you need command-specific suppression, you can add error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); at the beginning of your command’s handle() method.

Conclusion

Disabling deprecated messages in Laravel projects is an important step to optimize the performance, stability, and maintainability of your applications. By addressing deprecated messages promptly and following best practices, developers can ensure that their code remains clean, efficient, and up to date with the latest Laravel standards.

Key Takeaways:

  • APP_DEBUG=false does NOT suppress deprecation warnings
  • Use error_reporting configuration in config/app.php for the most reliable solution
  • php artisan optimize helps with caching but doesn’t suppress warnings alone
  • Laravel 7 users should consider upgrading to avoid PHP 8 compatibility issues
  • Always test your configuration changes in a development environment first

We encourage developers to take proactive steps to disable deprecated messages in their Laravel projects and ensure that their code is compliant with the best practices of the Laravel framework.

Need help with Laravel development?
Hire expert Laravel developers from SourceBae to handle your deprecation warnings and ensure your application runs smoothly.

Picture of Priyanshu Pathak

Priyanshu Pathak

Priyanshu Pathak is a Senior Developer at Sourcebae. He works across the stack to build fast, reliable features that make hiring simple. From APIs and integrations to performance and security, Priyanshu keeps our products clean, scalable, and easy to maintain.

Table of Contents

Hire top 1% global talent now

Related blogs

Introduction Picture this: A talented software engineer joins your IT company with excitement and big dreams. Fast forward 45 days,

Companies lose billions of dollars every year because of mistakes made during onboarding. Twenty percent of new workers leave within

Introduction You’ve hired a smart developer from a tier-2 college strong fundamentals, eager to learn, and importantly, more cost-effective than

Introduction What global tech talent onboarding means for European companies Global tech talent onboarding is the detailed process of bringing