1. Go to this page and download the library: Download laravel/doctor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Laravel\Doctor\EnvironmentMode;
public function check(): DiagnosticResult
{
if (config('queue.default') !== 'sync') {
return $this->pass('async');
}
if (EnvironmentMode::current()->isProduction()) {
return $this->warn('sync-in-production');
}
return $this->pass('sync-local');
}
namespace App\Doctor\Diagnostics;
use Illuminate\Support\Facades\Artisan;
use Laravel\Doctor\Contracts\Fixable;
use Laravel\Doctor\Diagnostic;
use Laravel\Doctor\EnvironmentMode;
use Laravel\Doctor\Results\DiagnosticResult;
use Laravel\Doctor\Results\FixResult;
use Laravel\Doctor\Results\Link;
use Laravel\Doctor\Results\Message;
class ApplicationKeyIsSet extends Diagnostic implements Fixable
{
public string $name = 'App key is set';
public string $group = 'environment';
protected function messages(): array
{
return [
'configured' => 'The application key is configured.',
'missing' => Message::make(
summary: 'The application key is not configured.',
remediation: 'Generate an application key with `php artisan key:generate`.',
confirmation: 'Generate an application key using `php artisan key:generate`?',
)->link(Link::docs('encryption')),
'generated' => 'The application key was generated.',
'generation-failed' => 'The application key could not be generated.',
];
}
public function check(): DiagnosticResult
{
$key = config('app.key');
if (is_string($key) && trim($key) !== '') {
return $this->pass('configured');
}
return $this->fail('missing')->fixable(EnvironmentMode::Local);
}
public function fix(DiagnosticResult $result): FixResult
{
Artisan::call('key:generate', ['--force' => true]);
$key = config('app.key');
if (! is_string($key) || trim($key) === '') {
return $this->fixFailed('generation-failed')
->withDetails(trim(Artisan::output()));
}
return $this->fixed('generated');
}
}
Message::make(
summary: 'Queued jobs run synchronously in production.',
remediation: 'Configure a background queue driver.',
)->link(Link::docs('queues', 'connections-vs-queues'));
'unsatisfied' => Message::make(
summary: 'PHP {version} does not satisfy [{constraint}].',
remediation: 'Use a PHP binary that satisfies the composer.json PHP constraint.',
),
public function fix(DiagnosticResult $result, ?string $option = null): FixResult
{
// $option is one of the declared option values...
}
->fixOptions(['file' => 'File'], decline: 'Keep Redis (repair it manually)');
use Laravel\Doctor\Support\Configured;
$connection = Configured::string('queue.default', 'database');
public function check(): DiagnosticResult
{
$missing = Configured::missing([
'services.stripe.key',
'services.stripe.secret',
]);
if ($missing === []) {
return $this->pass('set');
}
return $this->fail('missing')->withDetails(Details::bullets($missing));
}
use Laravel\Doctor\Support\ActiveDrivers;
$channels = ActiveDrivers::logChannels(Configured::string('logging.default', 'stack'));
$mailers = ActiveDrivers::mailers(Configured::string('mail.default', 'log'));
use Laravel\Doctor\Support\Details;
Details::bullets(['services.stripe.key', 'services.stripe.secret']);
Details::failures(['media' => 'The disk root is not writable.']);
Details::processOutput($process->output(), $process->errorOutput(), 'The command produced no output.');
use App\Doctor\Diagnostics\ApplicationKeyIsSet;
use Laravel\Doctor\Facades\Doctor;
public function boot(): void
{
Doctor::diagnostic(ApplicationKeyIsSet::class);
}
use Laravel\Doctor\Facades\Doctor;
use Vendor\Package\Diagnostics\HorizonIsRunning;
public function boot(): void
{
Doctor::diagnostic(HorizonIsRunning::class);
}
use Laravel\Doctor\Facades\Doctor;
$report = Doctor::run();
if ($report->hasFailures()) {
// ...
}
bash
php artisan doctor --only=storage
php artisan doctor --only=StorageIsWritable
php artisan doctor --only=vendor/package
php artisan doctor --except=laravel/*
php artisan doctor --except=laravel/doctor
php artisan doctor --except=storage