2017 © Pedro Peláez
 

library laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

image

beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

  • Friday, July 27, 2018
  • by beyondcode
  • Repository
  • 17 Watchers
  • 631 Stars
  • 5,235 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 30 Forks
  • 4 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Perform Self-Diagnosis Tests On Your Laravel Application

Latest Version on Packagist Total Downloads, (*1)

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., (*2)

Here is an example output of the command:, (*3)

All Checks passed, (*4)

Included checks

  • Is the APP_KEY set?
  • Are your composer dependencies up to date with the composer.lock file?
  • 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?
  • Is the maintenance mode disabled?
  • Are the required locales installed on the system?
  • 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?
  • Can Redis be accessed?

Development environment checks

  • Is the configuration not cached?
  • Are the routes not cached?
  • Are there environment variables that exist in .env but not in .env.example?

Production environment checks

  • Is the configuration cached?
  • Are the routes cached?
  • Is the xdebug PHP extension disabled?
  • Is APP_DEBUG set to false?
  • Are certain servers reachable?
  • Are certain supervisor programs running?

Installation

You can install the package via composer:, (*5)

composer require beyondcode/laravel-self-diagnosis

Usage

Just call the artisan command to start the checks:, (*6)

php artisan self-diagnosis

Customization

You can publish the configuration file, that contains all available checks using:, (*7)

php artisan vendor:publish --provider=BeyondCode\\SelfDiagnosis\\SelfDiagnosisServiceProvider

This will publish a self-diagnosis.php file in your config folder. This file contains all the checks that will be performed on your application., (*8)

<?php

return [

    /*
     * A list of environment aliases mapped to the actual environment configuration.
     */
    'environment_aliases' => [
        'prod' => 'production',
        'live' => 'production',
        'local' => 'development',
    ],

    /*
     * Common checks that will be performed on all environments.
     */
    'checks' => [
        \BeyondCode\SelfDiagnosis\Checks\AppKeyIsSet::class,
        \BeyondCode\SelfDiagnosis\Checks\CorrectPhpVersionIsInstalled::class,
        \BeyondCode\SelfDiagnosis\Checks\DatabaseCanBeAccessed::class => [
            'default_connection' => true,
            'connections' => [],
        ],
        \BeyondCode\SelfDiagnosis\Checks\DirectoriesHaveCorrectPermissions::class => [
            'directories' => [
                storage_path(),
                base_path('bootstrap/cache'),
            ],
        ],
        \BeyondCode\SelfDiagnosis\Checks\EnvFileExists::class,
        \BeyondCode\SelfDiagnosis\Checks\ExampleEnvironmentVariablesAreSet::class,
        \BeyondCode\SelfDiagnosis\Checks\LocalesAreInstalled::class => [
            'required_locales' => [
                'en_US',
                'en_US.utf8',
            ],
        ],
        \BeyondCode\SelfDiagnosis\Checks\MaintenanceModeNotEnabled::class,
        \BeyondCode\SelfDiagnosis\Checks\MigrationsAreUpToDate::class,
        \BeyondCode\SelfDiagnosis\Checks\PhpExtensionsAreInstalled::class => [
            'extensions' => [
                'openssl',
                'PDO',
                'mbstring',
                'tokenizer',
                'xml',
                'ctype',
                'json',
            ],
            'include_composer_extensions' => true,
        ],
        \BeyondCode\SelfDiagnosis\Checks\StorageDirectoryIsLinked::class,
    ],

    /*
     * Environment specific checks that will only be performed for the corresponding environment.
     */
    'environment_checks' => [
        'development' => [
            \BeyondCode\SelfDiagnosis\Checks\ComposerWithDevDependenciesIsUpToDate::class => [
                'additional_options' => '--ignore-platform-reqs',
            ],
            \BeyondCode\SelfDiagnosis\Checks\ConfigurationIsNotCached::class,
            \BeyondCode\SelfDiagnosis\Checks\RoutesAreNotCached::class,
        ],
        'production' => [
            \BeyondCode\SelfDiagnosis\Checks\ComposerWithoutDevDependenciesIsUpToDate::class => [
                'additional_options' => '--ignore-platform-reqs',
            ],
            \BeyondCode\SelfDiagnosis\Checks\ConfigurationIsCached::class,
            \BeyondCode\SelfDiagnosis\Checks\DebugModeIsNotEnabled::class,
            \BeyondCode\SelfDiagnosis\Checks\PhpExtensionsAreDisabled::class => [
                'extensions' => [
                    'xdebug',
                ],
            ],
            \BeyondCode\SelfDiagnosis\Checks\RedisCanBeAccessed::class => [
                'default_connection' => true,
                'connections' => [],
            ],
            \BeyondCode\SelfDiagnosis\Checks\RoutesAreCached::class,
            \BeyondCode\SelfDiagnosis\Checks\ServersArePingable::class => [
                'servers' => [
                    'www.google.com',
                    ['host' => 'www.google.com', 'port' => 8080],
                    '8.8.8.8',
                    ['host' => '8.8.8.8', 'port' => 8080, 'timeout' => 5],
                ],
            ],
            \BeyondCode\SelfDiagnosis\Checks\SupervisorProgramsAreRunning::class => [
                'programs' => [
                    'horizon',
                ],
                'restarted_within' => 300, // max seconds since last restart, 0 to disable check
            ],
        ],
    ],

];

Available Configuration Options

The following options are available for the individual checks:, (*9)

Custom Checks

You can create custom checks, by implementing the BeyondCode\SelfDiagnosis\Checks\Check interface and adding the class to the config file. Like this:, (*10)

<?php

use BeyondCode\SelfDiagnosis\Checks\Check;

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

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

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

Example Output

Some Checks failed, (*11)

Testing

bash composer test, (*12)

Changelog

Please see CHANGELOG for more information what has changed recently., (*13)

Contributing

Please see CONTRIBUTING for details., (*14)

Security

If you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker., (*15)

Credits

License

The MIT License (MIT). Please see License File for more information., (*16)

The Versions

09/07 2018

0.4.1

0.4.1.0 https://github.com/beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

beyondcode laravel-self-diagnosis

08/07 2018

0.4.0

0.4.0.0 https://github.com/beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

beyondcode laravel-self-diagnosis

06/07 2018

0.3.0

0.3.0.0 https://github.com/beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

beyondcode laravel-self-diagnosis

05/07 2018

0.2.0

0.2.0.0 https://github.com/beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

beyondcode laravel-self-diagnosis

04/07 2018

0.1.1

0.1.1.0 https://github.com/beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

beyondcode laravel-self-diagnosis

04/07 2018

0.1.0

0.1.0.0 https://github.com/beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

beyondcode laravel-self-diagnosis