Laravel Self-Diagnosis is a package by Marcel Pociot that performs self-diagnostics tests on your application. The checks include standard things like setting your APP_KEY environment variable when checking out a new project.

The full list of checks at the time of writing include:

  • Is the APP_KEY set?
  • Are your composer dependencies up to date?
  • Do you have the correct PHP version installed?
  • Do you have the correct PHP extensions installed?
  • Can a connection to the database be established?
  • Do the storage and bootstrap/cache directories have the correct permissions?
  • Does the .env file exist?
  • Are there environment variables that exist in .env.example but not in .env?
  • Are there any migrations that need to be run?
  • Is the storage directory linked?

In a team environment, comparing one’s .env file to the .env.example file is super helpful to make sure you have everything configured.

You can even create custom checks by implementing an interface and configuring the check:

<?php

use BeyondCodeSelfDiagnosisChecksCheck;

class MyCustomCheck implements Check
{
    /**
     * The name of the check.
     *
     * @return string
     */
    public function name(): string
    {
        return 'My custom check.';
    }

    /**
     * Perform the actual verification of this check.
     *
     * @return bool
     */
    public function check(): bool
    {
        return true;
    }

    /**
     * The error message to display in case the check does not pass.
     *
     * @return string
     */
    public function message() : string
    {
        return 'This is the error message that users see if "check" returns false.';
    }
}

Learn More

You can download this package at beyondcode/laravel-self-diagnosis. Marcel has been putting out a ton of excellent packages and content for the Laravel community. Earlier this week we covered his new course, Learn Laravel Forge. Last week we covered an update to Marcel’s Laravel Test Tools Chrome extension, which adds support for Dusk test cases.





Sumber: Laravel Blog