• Stars
    star
    1,386
  • Rank 33,910 (Top 0.7 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Perform Self-Diagnosis Tests On Your Laravel Application

Perform Self-Diagnosis Tests On Your Laravel Application

Latest Version on Packagist Build Status Quality Score Total Downloads

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:

All Checks passed

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:

composer require beyondcode/laravel-self-diagnosis

If you're using Laravel 5.5+ the SelfDiagnosisServiceProvider will be automatically registered for you.

Usage

Just call the artisan command to start the checks:

php artisan self-diagnosis

Customization

You can publish the configuration file, that contains all available checks using:

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.

<?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:

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:

<?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

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

More Repositories

1

laravel-websockets

Websockets for Laravel. Done right.
PHP
5,067
star
2

expose

A beautiful, fully open-source, tunneling service - written in pure PHP
PHP
4,221
star
3

laravel-er-diagram-generator

Generate entity relation diagrams from your Laravel model files.
PHP
1,905
star
4

laravel-query-detector

Laravel N+1 Query Detector
PHP
1,785
star
5

laravel-dump-server

Bring Symfony's Var-Dump Server to Laravel
PHP
1,477
star
6

writeout.ai

Transcribe and translate your audio files - for free
PHP
1,287
star
7

laravel-mailbox

Catch incoming emails in your Laravel application
PHP
973
star
8

laravel-vouchers

Allow users to redeem vouchers that are bound to models.
PHP
601
star
9

laravel-credentials

Add encrypted credentials to your Laravel production environment.
PHP
572
star
10

laravel-view-xray

Take a look into your Laravel views
PHP
572
star
11

dusk-dashboard

A beautiful dashboard for your Laravel Dusk tests
PHP
559
star
12

laravel-confirm-email

Add email verification to your Laravel projects
PHP
532
star
13

laravel-server-timing

Add Server-Timing header information from within your Laravel apps.
PHP
528
star
14

laravel-comments

Add comments to your Laravel application
PHP
426
star
15

livewire-devtools

Chrome and Firefox DevTools extension for debugging Livewire applications
JavaScript
390
star
16

laravel-websockets-demo

Demo application to use with the Laravel WebSockets package.
PHP
382
star
17

laravel-favicon

Create dynamic favicons based on your environment settings.
PHP
354
star
18

laravel-debugbar-companion

The Laravel DebugBar companion app
Vue
292
star
19

laravel-tag-helper

Add powerful HTML tag helpers to your Laravel application
PHP
236
star
20

tailwindcss-jit-cdn

Tailwind CSS JIT in your browser
JavaScript
229
star
21

laravel-ask-database

Query your database using natural language
PHP
218
star
22

laravel-tinker-server

Tinker with your variables while working on your Laravel application
PHP
207
star
23

banners

Create beautiful looking social images for your PHP packages
TypeScript
201
star
24

tailwind-jit-api

Use the full power of Tailwind CSS' new JIT compiler by including one script tag to your HTML.
JavaScript
166
star
25

laravel-visual-diff

Create visual diffs in your Laravel application tests.
PHP
161
star
26

github-now

Automatically generate your GitHub user profile page
PHP
140
star
27

nova-tinker-tool

Use the power of Tinker within your Nova application.
Vue
116
star
28

laravel-prose-linter

Syntax-aware proofreading for your Laravel application.
PHP
104
star
29

laravel-inline-translation

Add inline translation capabilities to your Laravel application.
PHP
104
star
30

httpdump

Easily inspect incoming HTTP Requests
PHP
104
star
31

forge-cli

An opinionated Laravel Forge CLI tool
PHP
100
star
32

laravel-masked-db-dump

Dump masked information from your database
PHP
96
star
33

nova-custom-dashboard-card

A Laravel Nova dashboard card that allows you to build custom dashboards.
Vue
86
star
34

slack-notification-channel

Laravel Slack notification channel with API token support instead of incoming webhooks.
PHP
85
star
35

helo-laravel

HELO Laravel helper package to add
PHP
84
star
36

chatgpt-clone

A ChatGPT clone using the new OpenAI chat completions API
PHP
81
star
37

laravel-scope-checks

Automatically convert your Eloquent scopes to boolean check methods.
PHP
78
star
38

laravel-package-tools

Use the make: commands that you know and love from Laravel - outside of Laravel.
PHP
71
star
39

laravel-fixed-window-limiter

PHP
69
star
40

invoker-community

63
star
41

tinkerwell-community

58
star
42

carbon-desktop-app

🎨 Create and share beautiful images of your source code - right from a native app.
JavaScript
57
star
43

nova-filterable-cards

Add custom filters to your Nova metric cards
Vue
56
star
44

tinkerwell-helper

Open Tinkerwell right from your Laravel apps.
PHP
55
star
45

laravel-sliding-window-limiter

Sliding Time Window Rate Limiter for Laravel
PHP
41
star
46

fathom-analytics-api

The unofficial Fathom Analytics API
PHP
39
star
47

laravelpackageboilerplate.com

PHP
36
star
48

skeleton-laravel

PHP
35
star
49

nova-laravel-update-card

Check if you're running the latest Laravel version right from your Nova dashboard.
PHP
34
star
50

windy-community

31
star
51

docs.beyondco.de

Documentation of the Beyond Code package.
HTML
22
star
52

nova-rss-card

Display custom RSS feeds on your Nova dashboard.
PHP
14
star
53

invoker-er-diagram-plugin

Generate ER Diagrams in Invoker
Vue
14
star
54

nova-installer

The Laravel Nova Package Installer
PHP
14
star
55

helo-community

Repository to discuss technical HELO issues, feature requests and more
13
star
56

laravel-badges

Built live on stage at Laracon Australia 2019
PHP
13
star
57

regexpress

12
star
58

skeleton-php

PHP
8
star
59

invoker-test-toolkit

Detect, run and evaluate your applications PHPUnit tests in Invoker.
Vue
7
star
60

laragone

PHP
7
star
61

tinkerwell-web-docs

Tinkerwell Web documentation with inline code snippets
7
star
62

forge-demo

PHP
6
star
63

devtoolsfortailwind-community

5
star
64

fathom-notifier

PHP
5
star
65

invoker-routes-plugin

A Invoker plugin that shows you a table for all of your registered Laravel routes
Vue
4
star
66

docs-example

Example repository to display the documentation structure
2
star
67

invoker-plugin-typings

1
star
68

github-notion-sync

Syncing issues of multiple repositories with a Notion database.
1
star