Milind Daraniya

Laravel Artisan Doctor: How to Automatically Detect Application Configuration and Environment Problems

Published September 17th, 2026 16 min read

When working on Laravel projects, many problems are not really coding problems.

The code can be completely correct, but the application may still not work because of a wrong environment variable, missing PHP extension, incorrect file permissions, missing application key, or some other configuration issue.

I have faced these types of problems many times in real projects.

Usually, I check the .env file, PHP version, installed extensions, storage permissions, cache, database connection, and other configuration manually.

Laravel now has Artisan Doctor, which is designed to check many of these common application problems automatically.

What Is Laravel Artisan Doctor?

Laravel Doctor is a diagnostic tool for Laravel applications.

It provides an Artisan command:

php artisan doctor

The command runs a collection of health checks against the Laravel application and reports problems that may prevent the application from working correctly.

Laravel introduced Doctor in 2026, and the package was initially released on July 22, 2026. It also allows third-party packages to register their own diagnostic checks.

For me, the main idea is simple:

Instead of manually checking many common Laravel problems, let Laravel check them for us.

Why This Is Useful

A Laravel application depends on many things outside the PHP code.

For example:

  • Correct PHP version
  • Required PHP extensions
  • .env configuration
  • APP_KEY
  • File permissions
  • Storage configuration
  • Cache configuration
  • Production settings
  • Application configuration

A developer can spend a lot of time checking these things one by one.

Doctor puts many of these checks into one command.

That is especially useful when setting up a new project, moving a project to another server, troubleshooting an existing application, or working with an AI coding agent.

Installing Laravel Doctor

Laravel Doctor is available as a development dependency.

Install it with:

composer require laravel/doctor --dev

The official Doctor repository documents this installation method.

After installing it, run:

php artisan doctor

This starts the diagnostic checks.

What Does Doctor Check?

Doctor checks different parts of the Laravel application environment.

Some of the important checks include:

  • Is APP_KEY configured?
  • Is the PHP version compatible with the project?
  • Are required PHP extensions installed?
  • Is the environment configuration complete?
  • Can Laravel write to required storage directories?
  • Is the application configured correctly for the current environment?

Laravel's announcement specifically mentions checks for the application key, PHP version, required extensions, and environment configuration.

This is useful because these are exactly the types of issues that can stop an otherwise correct application from running.

Example: Missing APP_KEY

One common Laravel setup problem is a missing application key.

For example, a new project may have an .env file but no valid:

APP_KEY=

Normally, I would notice this when the application starts throwing encryption-related errors.

Doctor can detect the missing key.

In cases where the problem has a deterministic fix, Doctor can also offer to repair it. Laravel's Doctor package includes a first-party fix for generating a missing APP_KEY.

This is better than manually remembering which Artisan command should be executed.

Example: PHP Extension Problem

Another common issue happens when the server has PHP installed but is missing a required extension.

For example, an application may depend on:

  • mbstring
  • openssl
  • pdo
  • pdo_mysql
  • curl
  • fileinfo
  • intl

The Laravel application may work on one machine and fail on another because the environments are different.

Doctor can check the required PHP extensions and report missing requirements.

This can save time when moving a Laravel application to a new server.

Example: Storage Permission Problem

Laravel applications frequently need write access to storage-related directories.

A permission problem can produce errors that look like application issues even though the real problem is the Linux filesystem.

For example:

The application cannot write to the required storage directory.

Doctor can identify storage write problems and, where a safe automatic repair is available, ask before applying the fix.

This is especially useful when deploying Laravel applications on Linux servers.

Automatic Fixes

This is one of the features I find more interesting.

Doctor does not only report problems.

For some problems, it can also suggest or perform a deterministic fix.

For example, the current Doctor package documents fixes for things such as:

  • Creating a missing .env
  • Generating APP_KEY
  • Disabling debug mode in production
  • Adding .env to .gitignore
  • Creating the public storage link
  • Repairing writable storage directories

Some fixes are interactive and ask for confirmation before changing anything.

That is a good approach because automatically changing server configuration without asking can be risky.

Using --fix

The Doctor package also provides a --fix option.

php artisan doctor --fix

This allows available fixes to be applied without interactive prompting.

I would still be careful with this option on production systems.

On a development machine, automatic fixes can be convenient.

On production, I prefer to understand what will change before applying it.

Doctor Is Not a Monitoring System

This is important.

Laravel Doctor is not the same thing as application monitoring.

It is not replacing:

  • Server monitoring
  • Error tracking
  • Application performance monitoring
  • Log monitoring
  • Uptime monitoring

Doctor is mainly a diagnostic and configuration health tool.

I would use it when I want to ask:

"Is this Laravel application environment correctly configured?"

Monitoring tools answer a different question:

"Is my production application currently healthy and behaving normally?"

Doctor and Deployment

I can also see Laravel Doctor being useful as part of deployment processes.

Imagine a normal deployment:

Pull latest code
    ↓
composer install
    ↓
run migrations
    ↓
clear/cache configuration
    ↓
restart workers
    ↓
run health checks

The last step can include:

php artisan doctor

This gives another validation step before considering the deployment complete.

The exact deployment workflow will depend on the application, but having a standard diagnostic command is useful.

Doctor for New Developers

Laravel has many conventions.

A developer who is new to Laravel may not immediately know that a problem is caused by:

  • .env
  • APP_KEY
  • file permissions
  • PHP version
  • missing extensions
  • storage configuration

Instead of searching for each problem separately, they can start with:

php artisan doctor

This gives them a better starting point for debugging.

It does not solve every possible problem, but it can remove many common environment-related issues.

Doctor for Large Laravel Projects

I work with large applications where the environment can be more complicated than a small Laravel project.

There can be:

  • Multiple developers
  • Different local environments
  • Different PHP versions
  • Multiple databases
  • Redis
  • Queue workers
  • Scheduled jobs
  • Storage services
  • Different .env settings
  • Development and production servers

When something stops working, the first question is often:

Is this a code problem or an environment problem?

Doctor can help answer that question faster.

Third-Party Package Diagnostics

Another useful part of Laravel Doctor is that the diagnostic system is not limited to Laravel itself.

The Doctor package allows third-party packages to register their own diagnostic checks.

This is a good idea because packages often have their own requirements.

For example, a package may require:

  • A special PHP extension
  • A configuration value
  • A database setting
  • A filesystem configuration
  • A required environment variable

Instead of asking developers to remember all package-specific requirements, packages can expose their own diagnostics.

That can make Laravel applications easier to troubleshoot.

Doctor and AI Coding Agents

This is another area where I think Doctor becomes interesting.

AI coding agents can write code very quickly.

But after making changes, the agent still needs to verify that the application is in a good state.

Laravel specifically described Artisan Doctor as a natural final sanity check for AI coding agents.

A simple workflow could be:

AI changes code
      ↓
Run tests
      ↓
Run static analysis
      ↓
Run Laravel Doctor
      ↓
Check remaining problems
      ↓
Finish task

This is a better workflow than asking an AI agent to simply change files and assume everything is fine.

The agent can make a change, run the checks, see the result, and continue fixing problems.

Doctor vs Laravel about

Laravel already has commands that can show useful application information.

For example:

php artisan about

is useful for viewing application and environment information.

Doctor has a different purpose.

about helps me understand the environment.

Doctor helps me find problems in the environment.

That difference makes the two commands useful for different situations.

Doctor vs Manual Debugging

Without Doctor, a developer might do something like this:

php -v

Then:

php -m

Then inspect:

.env

Then check:

ls -la storage

Then check configuration.

Then check other project requirements.

There is nothing wrong with this approach.

The problem is that it takes time and developers may forget one of the checks.

A standard diagnostic command makes the first troubleshooting step much simpler:

php artisan doctor

Should You Run Doctor in Production?

I would not treat Doctor as a replacement for production monitoring.

But it can be useful during deployment or troubleshooting.

For example, after deploying a new version, a team can run a controlled diagnostic check to verify that the environment still satisfies the application's requirements.

For production, I would also consider:

  • Logs
  • Error tracking
  • Health endpoints
  • Database monitoring
  • Queue monitoring
  • Server monitoring
  • Application performance monitoring

Doctor can be one part of that overall process.

A Practical Workflow I Would Use

For a new Laravel project, I would keep the workflow simple.

First install the dependencies:

composer install

Then configure .env.

After that:

php artisan doctor

Then fix any reported problems.

Then:

php artisan migrate

Then run the application and tests.

For an existing project, I would use Doctor when I see an environment-related problem rather than immediately changing application code.

Final Thoughts

I have spent many years working with PHP and Laravel, and one thing I have learned is that debugging is not always about finding a bug in the code.

Sometimes the code is correct.

The server is wrong.

The PHP version is wrong.

A required extension is missing.

A directory is not writable.

A configuration value is missing.

Or the environment was simply not prepared correctly.

Laravel Artisan Doctor is useful because it brings many of these checks into one simple command.

php artisan doctor

I especially like the idea of packages being able to add their own diagnostic checks. That can make large Laravel applications much easier to troubleshoot as the number of dependencies grows.

For me, Doctor is not a replacement for proper testing, monitoring, or deployment practices.

It is a practical extra check that can save time before I start debugging the wrong part of the application.