Laravel Self-Diagnosis Package
Published on by Paul Redmond
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
andbootstrap/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.'; }}
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.