49

Laravel Self-Diagnosis Package

 5 years ago
source link: https://www.tuicool.com/articles/hit/emUBbqZ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.

It happened to all of us @laravelphp devs:

We forgot to generate the APP_KEY, our .env.example has keys that our .env file is missing, we forgot to do a composer install, …

Here's our Laravel Self Diagnosis package to help you ???? https://t.co/wZdSpyCfn9 pic.twitter.com/qaWlDyJBuf

— Marcel Pociot (@marcelpociot) July 4, 2018

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 BeyondCode\SelfDiagnosis\Checks\Check;

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.';
    }
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK