Laravel Self-Diagnosis Package

Packages

July 5th, 2018

laravel-self-diagnosis.jpg

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:

1<?php
2
3use BeyondCode\SelfDiagnosis\Checks\Check;
4
5class MyCustomCheck implements Check
6{
7 /**
8 * The name of the check.
9 *
10 * @return string
11 */
12 public function name(): string
13 {
14 return 'My custom check.';
15 }
16
17 /**
18 * Perform the actual verification of this check.
19 *
20 * @return bool
21 */
22 public function check(): bool
23 {
24 return true;
25 }
26
27 /**
28 * The error message to display in case the check does not pass.
29 *
30 * @return string
31 */
32 public function message() : string
33 {
34 return 'This is the error message that users see if "check" returns false.';
35 }
36}

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.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.