beyondcode / laravel-self-diagnosis
- пятница, 6 июля 2018 г. в 06:46:32
PHP
Perform Self-Diagnosis Tests On Your Laravel Application
This package allows you to run self-diagnosis tests on your Laravel application. It comes with multiple checks out of the box and allows you to add custom checks yourself.
Here is an example output of the command:
storage and bootstrap/cache directories have the correct permissions?.env file exist?.env.example but not in .env?You can install the package via composer:
composer require beyondcode/laravel-self-diagnosisIf you're using Laravel 5.5+ the SelfDiagnosisServiceProvider will be automatically registered for you.
Just call the artisan command to start the checks:
php artisan self-diagnosisYou can publish the configuration file, that contains all available checks using:
php artisan vendor:publish --provider=BeyondCode\\SelfDiagnosis\\SelfDiagnosisServiceProviderThis will publish a self-diagnosis.php file in your config folder. This file contains all the checks that will be performed on your application.
<?php
return [
/*
* List of all the environment names that are considered as "production".
*/
'productionEnvironments' => [
'prod',
'production',
],
/*
* Common checks that will be performed on all environments.
*/
'checks' => [
\BeyondCode\SelfDiagnosis\Checks\AppKeyIsSet::class,
\BeyondCode\SelfDiagnosis\Checks\ComposerIsUpToDate::class,
\BeyondCode\SelfDiagnosis\Checks\CorrectPhpVersionIsInstalled::class,
\BeyondCode\SelfDiagnosis\Checks\DatabaseCanBeAccessed::class,
\BeyondCode\SelfDiagnosis\Checks\MigrationsAreUpToDate::class,
\BeyondCode\SelfDiagnosis\Checks\PhpExtensionsAreInstalled::class,
\BeyondCode\SelfDiagnosis\Checks\EnvFileExists::class,
\BeyondCode\SelfDiagnosis\Checks\ExampleEnvironmentVariablesAreSet::class,
\BeyondCode\SelfDiagnosis\Checks\DirectoriesHaveCorrectPermissions::class,
\BeyondCode\SelfDiagnosis\Checks\StorageDirectoryIsLinked::class,
],
/*
* Production environment specific checks.
*/
'production' => [
\BeyondCode\SelfDiagnosis\Checks\Production\ConfigurationIsCached::class,
\BeyondCode\SelfDiagnosis\Checks\Production\RoutesAreCached::class,
\BeyondCode\SelfDiagnosis\Checks\Production\XDebugIsNotEnabled::class,
\BeyondCode\SelfDiagnosis\Checks\Production\DebugModeIsNotEnabled::class,
],
/*
* Development environment specific checks.
*/
'development' => [
\BeyondCode\SelfDiagnosis\Checks\Development\ConfigurationIsNotCached::class,
\BeyondCode\SelfDiagnosis\Checks\Development\RoutesAreNotCached::class,
],
];You can create custom checks, by implementing the BeyondCode\SelfDiagnosis\Checks\Check interface and adding the class to the config file.
Like this:
<?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.';
}
}composer testPlease see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.